abc

Share This blog with your friends, so that we can improve more & more . our aim is to easy & simple way of learning.
Showing posts with label JQUERY. Show all posts
Showing posts with label JQUERY. Show all posts

12/13/2020

how to create alert, toast, tooltip

 in this tutorial give details of how to create alert OR toast OR tooltip on time basis, i.e. auto hide.



$(document).ready(function(){

  $('#myBtn').click(function(){

    $('.toast').toast({delay: 3000});

    $('.toast').toast('show');

  });

});


& call bootstrap supported files


finally, the code like below,

<!DOCTYPE html>

<html lang="en">

<head>

  <title>alert style </title>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

</head>

<body>


<div class="container mt-3">

  <h1>create toast or alert</h1>

   

  <p>In this example, it will take 3 seconds to hide the toast(alert box), once it is shown. </p>

  <button type="button" class="btn btn-primary" id="myBtn">Show Toast</button>


  <div class="toast mt-3">

    <div class="toast-header">

      Toast Header

    </div>

    <div class="toast-body">

      Some text inside the toast body

    </div>

  </div>

</div>


<script>

$(document).ready(function(){

  $('#myBtn').click(function(){

    $('.toast').toast({delay: 3000});

    $('.toast').toast('show');

  });

});

</script>


</body>

</html>


in above use jquery set delay in alert box and autohide.


useful to show messages or warning, success, error messages .

for example data is saved message for this also good to use toast.

4/07/2019

Disable a div on selecting an option from a drop down menu in HTML

1. make simple dropdown menu
<select id="selelctme">
<option>AABC</option>
<option>BDIV</option>
<option>CDFG</option>
</select>

2. add script
<script>
 $(document).ready(function(){
 $('#selectme').change(function(){
 if($(this:selected).val()=='BDIV')
{
 $('.BDIV').attr('disabled','true');
}
else
{
}

});

});

</script>

in  above simplly use change function this also can be add using javascript onchange function.

5/06/2018

Jquery Siblings

what is jquery Siblings
in general life siblings are different from this siblings so don't confuse,
ok now let us detail example of siblings


<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>let us see what is siblings</title>
  <style>
  ul {
    float: left;
    margin: 15px;
    font-size: 6px;
    font-weight: bold;
  }
  p {
    color: blue;
    margin: 1px 2px;
    font-size: 5px;
    padding: 5px;
    font-weight: bold;
  }
  .abc {
    background: yellow;
  }
  </style>
  <script src="https://code.jquery.com/jquery.min.js"></script>
</head>
<body>

<ul>
  <li>One</li>
  <li>Two</li>
  <li class="abc">Three</li>
  <li>Four</li>
</ul>


<p>Unique siblings: <b></b></p>

<script>
var anytemp = $( ".abc" ).siblings().css( "color", "red" ).length;
$(".ab").text(anytemp);
</script>

</body>
</html>


in above example use anytemp variable after find siblings we append anytemp variable to ab div.
 in short siblings,
1. get all related siblings
2. apply style to relevant siblings
3. this is traversing sideways.
4.  can get all previous & next value of parent div

in following image shows detail of how siblings & traversing work & affect.
Fig : Jquery Traversing & Siblings.


please comment if any query

jQuery Traversing

hi,

what is jquery traversing,
traversing is used to find specific div such as particular div of parent class by moving through whole class.

 this basically change DOM , also effect on ancestor, descendants, siblings
for example

$(document).ready(function(){
    $(".abc").parent().css({"color": "red", "border": "4px solid red"});
});

 basically following method ,
1. parent()
2. parents()
3. children()
4. find()
5. parentsuntil()
6.  siblings()
7.   next()
8.  nextAll()
9.  nextUntil()
10  prev()
11 prevAll()
12 prevUntil()

in above parent() method is use for getting direct parent class in above example apply red color style abc parent div .
similarly parents is use for multiple surrounded or all div that cover children div.
children()
eg:  $('.may').children().css('color': 'yellow');

 in similar way if you want to find specific div
$('#ab').find("span").css('border','2px solid green');
 above example shows border color green for span find in ab div
 $("div").find("*");
to find all element in div .


 

5/03/2018

Jquery Function & effect on HTML element

hi

today let us continue previous session

1) before() : is use to insert content before perticular element such as insert before div or paragraph

eg: $('#ab'').before('hello hi how are you');

2) prepend() : is use for insert content before all same element

$("p").prepend("<b>hi sample text</b>");

3) append() : similarly use for appending to perticular element
eg:
<script>
$(document).ready(function(){
    $("#ab").click(function(){
        $(".div").append(" <b>Appended hello</b>.");
    });

    $("#cd").click(function(){
        $(".div").append("<li>Appended hi</li>");
    });
});
</script>

4) empty() : is use to empty div element.

eg: $(div).empty();

5) detach() : is use for detach element from main element or parent content

eg: $(p).remove() ---remove p from main div

6) scrolltop() : is use for scroll move to top from its position

<script>
$(document).ready(function(){
    $("button").click(function(){
        alert($("div").scrollTop() + " px");
    });
});
</script>

above exmple shows where is position of div & alert message


7) Delay()
is use to set delay

eg: $("#ab1").delay("5").fadeIn();
    $("#ab2").delay("fast").SlideIn();

in this way we see detail of jquery function
next time we will see more & new session ..


5/01/2018

JQUERY with HTML & CSS

hi,

main difference between text & html method

Sometimes, i think both are same to set or return the html content. But, the jQuery text() method is different from html() method.
Following is the main differences:
  • The jQuery text() method is used to set or return html content without HTML markup while, html() method is used to set or return the innerHtml (text + HTML markup).
  • The jQuery text() method can be used in both XML and HTML document while jQuery html() method can not.

syntax are three ways,
$(selector).text();
$(selector).text("abcd");  
$(selector).text(function(index,currentcontent)) ;

if you look above syntax there are difference in all syntax ,
 above first syntax is use for return or get text content in html tag.
second syntax is use for set content in html tag
& third is using function.
 

    an example of html & jquery
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>  
  5. <script>  
  6. $(document).ready(function(){  
  7.     $("button").click(function(){  
  8.         $("p").text("hi abc!");  
  9.     });  
  10. });  
  11. </script>  
  12. </head>  
  13. <body>  
  14. <button>hi click me</button>  
  15. <p>Hello Guys!</p>  
  16. <p>Looking for online training....</p>  
  17. </body>  
  18. </html> 
try code & run in browser you can view output.

similarly html method happen but it change all entire content.
  1. $(selector).html()
  2. $(selector).html(content)
  3. $(selector).html(function (index, currentcontent))


<!DOCTYPE html> 
<html> 
<head> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
<script> 
    $(document).ready(function(){ 
        $("button").click(function(){ 
            alert($("p").html()); 
        }); 
    }); 
    </script> 
</head> 
<body> 

<button>Return the content of p element</button> 

<p>
This is first <b>paragraph</b>.</p>
<p>
This is another <b>paragraph</b>.</p>
</body> 
</html> 






in next session we view more method such as before() , prepend(), append(), empty(), detach(), scrolltop(), delay()

4/20/2018

How animated jQuery affect on chart

Hi everyone welcome again today we are going to show more details on animated jQuery.

$(document).ready(function () {
            $('#chart).animate({
                title: { text: 'Animation' },
                animation: {
                    enabled: true,
                    delayTime: 1,
                    duration: 2
                },
                series: [
                    {
                        type: 'column',
                        title: 'Column',
                        data: [['A', 49], ['B', 35], ['C', 68], ['D', 30], ['E', 27], ['F', 85], ['D', 43], ['H', 29]]
                    },
                    {
                        type: 'line',
                        title: 'Line',
                        data: [['A', 69], ['B', 57], ['C', 86], ['D', 23], ['E', 70], ['F', 60], ['D', 88], ['H', 22]]
                    }
                ]
            });
        });

Above example shows chart change per second you can in showing company profit, share market position,
Chart are very important according to mathematical functions it is pictorial representation of value.
Hence chart are very important.
Suppose you have website and show company growth status then is very good to learn.
Remember the following points.
1) Animation is increasing user impression.
2) animation shows clear image representation.
3) image slider uses animation.
4) animation helps to perform any action with certain instances of time.
5) animation is very easy to learn.
6) also remember is not harm site or not increase loading time.
Thanks for viewing session...
We can continue in next session.

4/19/2018

Session 10: How To Make Animation Using Jquery

hi ,
welcome again ,
today we are going to start session 10 , an interesting session based on making animation. anyone can make animation. there are different way of making animation ,from this here we are showing jquery animation.
let us see below example:

$('document').ready(function()
{
$('.button').click(function(){
    $(".abc").animate({
        height: "toggle";
    });
});  

}); 


in above simple example if you click on button an div whose class abc showing height zero to original & if you click again it reverse.

now let us see more detail:
 

$('.button').click(function(){
    var div = $(".abc");
    div.animate({right: '330px'}, "slow");
    div.animate({font-size: '9pt'}, "slow");
}); 
  
in above example div get animated to right with change font size.
note: above animation support in all browser
 * see be careful this example 
$(document).ready(function(){
 // Start animation
 $(".start-btn").click(function(){
 $("img").animate({left: "+=150px"}, 2000);
    });

    // Stop running animation

    $(".stop-btn").click(function(){

      $("img").stop();

    });

    // Start animation in the opposite direction

    $(".back-btn").click(function(){

      $("img").animate({left: "-=150px"}, 2000);

    });

    // Reset to default

    $(".reset-btn").click(function(){

      $("img").animate({left: "0"}, "fast");

    });

});
above example of image animation in which affect using three button reset, back , stop button

we will more detail & intresting example in next session.
thanks for viewing please share & comment. which will help to give more knowledge.

4/13/2018

Jquery & AJAX connectivity, working of jquery with ajax











hi everyone,
today i am going to show you next learning session which depends on jquery & ajax(asynchrnous javascript) & connectivity.

for this let see below example


eg:
      <script type = "text/javascript"
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
       
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
            $("#sampl").click(function(event){
               var name = $("#name").val();
               $("#abc").load('/jquery/abc.php', {"name":name} );
            });
         });
      </script>
   </head>
   
   <body>
      <p>Enter your name and click on the button:</p>
      <input type = "input" id = "name" size = "400" /><br />
       
      <div id = "abc" style = "background-color:00ccff;">
        
      </div>
       
      <input type = "button" id = "sampl" value = "check if value" />

above example load an abc.php file
& with ajax if click on button it gets var name from file & result is abc.


let us another example  of ajax

$('.btn').click(function() {
 
  $('.text').text('loading . . .');
 
  $.ajax({
    type:"GET",
    url:"abc.com",
    success: function(data) {
      $('.text').text(JSON.stringify(data));
    },
    dataType: 'jsonp',
  });
 
});

if click on button current value of text div get & replace with loading text.
in this exmple also use jsonp & from this url whatever data , get it string.


above exmple
uses,
stringify, jsonp , get method, sucess funciton & follow url , button click funtion.
so this good & pretty simple exmple to learn .


we will continue detail in next session.

thanks for viewing blog, share with friends & all.





4/01/2018

Advanced Session on Jquery language




Connect Laptop To Computer and laptop To TV Connectivity.











hey everyone

today i am going to show what is jquery

jquery has library of javascript. which is very easy programming languages

let us learn some advance of jquery language.

1. what is traversing function in jquery.

$('span').not('.trial, .abc'); this is example of traversing:  traversing means select such span which has not name trial or abc.

2. jquery chaining
as name is chain for method this is basically help to join multiple function to each other.
eg:
 $("#abc").click(function(e) {
 alert("click!");
 }).mouseover(function(e) {
 alert("mouse is here!")
 }).mouseout(function(e) {
 alert("mouse oh!hhh gone")
 });

3. siblings for finding similar  of element

eg:$('h1').siblings();

4. ajax get & post
$('#abc').click(funciton(){
$.get("abc.txt", function(data, status){
        alert("Data: " + data + "\nStatus: " + status);
    });
});

5. please like & share to all
if you have any query please comment.
visit our blog learnmayuinfosyssolutions.blogspot.in .

thanks For Watching.


An Introduction to the Laravel Framework: What It Is and Why You Should Use It

  If you're a PHP developer looking for a modern, efficient, and powerful framework to build web applications, look no further than Lara...