jquery 节点

1. .each()
.each() 方法用于遍历 jQuery 对象集合中的每个元素。
$(selector).each(function(index, element) {
    // `this` is the current DOM element
    console.log(index, element);
});

2. .find()
.find() 方法用于在当前集合的每个元素的子元素中查找匹配的元素。
$(selector).find('childSelector').each(function() {
    // `this` is the current child DOM element
    console.log(this);
});

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 @ 2024-06-21 16:23  楼前竹  阅读(9)  评论(0)    收藏  举报