JQuery常用的api[最好是系统地学习一下《锋利的JQuery》]

text

http://api.jquery.com/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

http://api.jquery.com/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

http://api.jquery.com/val/

Get the current value of the first element in the set of matched elements or set the value of every matched element.

 

each

https://api.jquery.com/each/

 

.prop()

http://api.jquery.com/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()

https://api.jquery.com/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()

https://api.jquery.com/eq/

Reduce the set of matched elements to the one at the specified index.

 

.on()

http://api.jquery.com/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.

 

.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.

 

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(193)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2017-02-24 Pascal Script
点击右上角即可分享
微信分享提示