.change() in jQuery

It helps to bind an event handler to the “change” JavaScript event, or trigger that event on an element.

.change()

// To add an alert text, when an < input> field is changed:.

$(“input”).change(function(){
alert(“Handler for .change() called.The text has been changed.”);
});

Read more

:checkbox Selector in jQuery

It helps to select all elements of type checkbox.

:checkbox Selector

// To add background color on checkboxes. (Firefox does not support background)

$(document).ready(function(){
    $(“:checkbox”).wrap(“<span style=’background-color:yellow’ />”);
})

Read more

:checked Selector in jQuery

It helps to select all elements that are checked or selected.

:checked Selector

// To add background color to checked checkboxes. (Firefox does not support background)

$(document).ready(function(){
    $(“:checked”).wrap(“<span style=’background-color:yellow’ />”);
})

Read more

.children() in jQuery

It helps get the children of each element in the set of matched elements, optionally filtered by a selector.

.children()

// To add border and text color of “li” in “ul”.

<ul>
  <li>style will affect here
    <span>contents</span>
  </li>
</ul>

$(document).ready(function(){
  $(“ul”).children().css({“color”:”yellow”,”border”:”2px solid yellow”});
});

Read more

.clearQueue() in jQuery

It helps to stop the remaining functions in the queue:

.clearQueue()

// To stop animation using clearQueue() .

$(document).ready(function(){
  $(“#start”).click(function(){
       $(“div”).animate({height:100},1200);
       $(“div”).animate({width:100},1200);
       $(“div”).animate({height:200},1700);
       $(“div”).animate({width:200},7500);
  });
  $(“#stop”).click(function(){
       $(“div”).clearQueue();
  });
});

Read more

.click() in jQuery

It helps to bind an event handler to the “click” JavaScript event, or trigger that event on an element.

.click()

// if we click on this element, the alert is displayed

$( “#target” ).click(function() {
    alert( “Handler for .click() called.” );
});

Read more

.clone() in jQuery

It helps to create a copy of the set of matched elements.

.clone()

//Please refer following example with normal copy and using .clone()

<div class=”container”>
    <div class=”section01″>Data01</div>
    <div class=”section02″>Data02</div>
</div>

//Normally it is moved from its old location. So, given the code
$( “.section01” ).appendTo( “.section02” );

<div class=”container”>
    <div

Read more