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.
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2017-02-24 Pascal Script