MENU
Values
.data(String key, Any value)<br>.data(Object o)Associate data with the matched elements..each(function(int index, Element e) f)<br>Execute a function for each matched element.<br>.is(String/Element/jQuery selector)<br>.is(function(int index, Element e) f)Return true if at least one of the matched elements matches the arguments..end()<br>End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.<br><br>.get()<br>.toArray()<br>Return an array of matched elements.<br><br>.get(int index) [index]<br>Retrieves one element.<br><br>.index([String/Element/jQuery selector])<br>Return an integer indicating the position of the first matching element.<br><br>.length<br>Return the number of matched elements.<br><br>.map(function(int index, Element e) f)<br>Pass each matched element through a function, producing a new jQuery object containing the return values.<br><br>.removeData(String/Array name)<br>Remove a previously-stored piece of data.<br>.text()<br>.text(String/Number/Boolean data)<br>.text(function(int index, String text))<br>Get/set the combined text contents of each matched element.
RESETRUNFULL
RESETRUNFULL
Consider the following example:
<p id="1">A</p>
<p id="2">B</p>
<p id="3">C</p>
$('p').data('v1',100);$('p').data({v2:200});alert($('p:last').data('v1')+$('p:first').data('v2'));$('p').removeData('v1 v2');GIVESalerts 300
$('p').each(function(i){
alert($(this)[0].innerHTML + i);});GIVESalerts A0 … alerts B1 … alerts C2
alert($('p').is('p:first'));GIVESalerts true
$('body').find('p:first').css('color','red').end()
.find('p:last').css('color','green');
alert($( "p" ).map(function() {
return this.id;}).get().join());GIVES1,2,3
alert($('body').text());GIVESABCalert($('body').text());
alert($('p').toArray()[0].innerHTML);GIVESA