JQuery常用的api[最好是系统地学习一下《锋利的JQuery》]
text
Get the combined text contents of each element in the set of matched elements, including their descendants后裔, or set the text contents of the matched elements.
html
Get the HTML contents of the first element in the set of matched elements or set the HTML contents of every matched element.
val
Get the current value of the first element in the set of matched elements or set the value of every matched element.
each
.prop()
Get the value of a property for the first element in the set of matched elements or set one or more properties for every matched element.
.parent()
https://api.jquery.com/parent/
Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
.next()
Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
.eq()
Reduce the set of matched elements to the one at the specified index.
.on()
Attach an event handler function for one or more events to the selected elements.
http://live.datatables.net/depawowa/1/edit
jQuery.data()
https://api.jquery.com/jquery.data/
Store arbitrary data associated with the specified element and/or return the value that was set.
Contents:
.toggleClass()
http://api.jquery.com/toggleclass/
Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.
使用场景http://live.datatables.net/kuwaduta/1/edit
jQuery.each
http://api.jquery.com/jquery.each/
$(this)
https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
Use each: 'i
' is the postion in the array, obj
is the DOM object that you are iterating (can be accessed through the jQuery wrapper $(this)
as well).
$('.testimonial').each(function(i, obj) {
//test
});
Check the api reference for more information.