Jquery Filtering
jQuery Traversing - Filtering
The first(), last(), eq(), filter() in addition to not() Methods
The virtually basic filtering methods are first(), last() in addition to eq(), which allow you lot to direct a specific chemical subdivision based on its position inward a grouping of elements.Other filtering methods, similar filter() in addition to not() allow you lot to direct elements that match, or produce non match, a sure enough criteria.
jQuery first() Method
The first() method returns the kickoff chemical subdivision of the specified elements.The next instance selects the kickoff <div> element:
Example
$(document).ready(function(){
$("div").first();
});
jQuery last() Method
The last() method returns the end chemical subdivision of the specified elements.The next instance selects the end <div> element:
Example
$(document).ready(function(){
$("div").last();
});
jQuery eq() method
The eq() method returns an chemical subdivision amongst a specific index publish of the selected elements.The index numbers start out at 0, in addition to then the kickoff chemical subdivision volition bring the index publish 0 in addition to non 1. The next instance selects the mo <p> chemical subdivision (index publish 1):
Example
$(document).ready(function(){
$("p").eq(1);
});
jQuery filter() Method
The filter() method lets you lot specify a criteria. Elements that produce non stand upward for the criteria are removed from the selection, in addition to those that stand upward for volition live returned.The next instance returns all <p> elements amongst cast refer "intro":
Example
$(document).ready(function(){
$("p").filter(".intro");
});
jQuery not() Method
The not() method returns all elements that produce non stand upward for the criteria.Tip: The not() method is the contrary of filter().
The next instance returns all <p> elements that produce non bring cast refer "intro":
Example
$(document).ready(function(){
$("p").not(".intro");
});
Comments
Post a Comment