jquery 节点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
1. .each()
.each() 方法用于遍历 jQuery 对象集合中的每个元素。
$(selector).each(function(index, element) {
    // `this` is the current DOM element
    console.log(index, element);
});<br><br>2. .find()
.find() 方法用于在当前集合的每个元素的子元素中查找匹配的元素。
$(selector).find('childSelector').each(function() {
    // `this` is the current child DOM element
    console.log(this);
});<br><br>3. .children()
.children() 方法用于获取当前集合中每个元素的直接子元素。
$(selector).children().each(function() {
    // `this` is the current child DOM element
    console.log(this);
});4. .parent()
.parent() 方法用于获取当前集合中每个元素的直接父元素。
$(selector).parent().each(function() {
    // `this` is the current parent DOM element
    console.log(this);
});
 
5. .parents()
.parents() 方法用于获取当前集合中每个元素的所有祖先元素。
$(selector).parents().each(function() {
    // `this` is the current ancestor DOM element
    console.log(this);
});
 
6. .siblings()
.siblings() 方法用于获取当前集合中每个元素的所有兄弟姐妹元素。
$(selector).siblings().each(function() {
    // `this` is the current sibling DOM element
    console.log(this);
});
 
7. .next()
.next() 方法用于获取当前集合中每个元素的下一个兄弟元素。
$(selector).next().each(function() {
    // `this` is the next sibling DOM element
    console.log(this);
});
 
8. .prev()
.prev() 方法用于获取当前集合中每个元素的上一个兄弟元素。
$(selector).prev().each(function() {
    // `this` is the previous sibling DOM element
    console.log(this);
});

  

  

posted @   楼前竹  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
历史上的今天:
2022-06-21 mysql 单独导出数据结构、表数据
点击右上角即可分享
微信分享提示