首页 > 其他分享 >jquery 节点

jquery 节点

时间:2024-06-21 16:34:23浏览次数:12  
标签:jquery console log DOM 元素 element each 节点

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);
});

  

  

标签:jquery,console,log,DOM,元素,element,each,节点
From: https://www.cnblogs.com/louqianzhu/p/18260786

相关文章

  • jquery文本操作、样式属性操作、效果学习
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>Document</title>......
  • Day56 代码随想录打卡|二叉树篇---删除二叉搜索树中的节点
    题目(leecodeT450):给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的 key 对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。一般来说,删除节点可分为两个步骤:首先找到需要删除的节点;如果找到了,删除它。方法:二叉搜索......
  • Leedcode【222】. 完全二叉树的节点个数——Java解法(递归)
    Problem: 222.完全二叉树的节点个数题目思路解题方法复杂度Code效果题目给你一棵完全二叉树的根节点root,求出该树的节点个数。完全二叉树的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的......
  • 学生个人html静态网页制作 基于HTML+CSS+JavaScript+jquery仿苏宁易购官网商城模板
    ......
  • jquery 参数学习
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>jquery使用</title>......
  • JQuery高级29_案例3
    一、广告的自动显示与隐藏需求:1.当页面加载完,3秒后,自动显示广告2.广告显示5秒后,自动消失。分析:1.使用定时器来完成。setTimeout(执行一次定时器)2.分析发现JQuery显示隐藏动画效果其实就是控制display3.使用show/hide方法来完成广告的显示<!DOCTYPEh......
  • JQuery高级29_事件绑定2
    一、jquery标准的绑定方式jq对象.事件方法(回调函数);注:如果调用事件方法,不传递回调函数,则会触发浏览器默认行为。表单对象.submit();//让表单提交<!DOCTYPEhtml><html><head><metacharset="UTF-8"><title>jquery标准的绑定方式</title......
  • Jquery ajax加载等待执行结束再继续执行下面代码操作
    Jquery等待ajax执行完毕再继续执行下面代码的效果,具体代码如下,其实就是将jqueryajax函数的async参数设置为false即可,该参数默认为true:$(document).ready(function(){loadphpernote();window.open('http://www.phpernote.com');});functionloadphpernote(){......
  • matlab有向网络节点之间最短路经计算
      clc;clear;%定义边列表(源节点,目标节点,权重)w1=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];s1=[1,1,1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,4,5,6,7,7,8,9,10,10,10,11,11,11,12,13,14,14,15,15,15,16,17,18,......
  • JQuery高级29_动画&遍历1
    一、动画三种方式显示和隐藏元素1、默认显示和隐藏方式 1.show([speed,[easing],[fn]]) 参数:   1.speed:动画的速度。三个预定义的值("slow","normal","fast")或表示动画时长的毫秒数值(如:1000)   2.easing:......