jQuery遍历节点
html代码
<div><p>武汉长乐教育</p><span>在哪才能真正学习会PHP技术?</span><a href="#"><p>欢迎前来试听</p></a></div>
children()方法
var $child = $("div").children(); //获取div元素的子类元素alert($child.length); //打印div元素有几个子类元素$("div").children("p"); //获取div元素的子类元素p
next()方法
var $a = $("div span").next(); //获取下一个同辈的元素
prev()方法
var $p = $("div span").prev(); //获取上一个同辈的元素
siblings()方法
<ul><li>一对一授课哦</li><li>学完高薪就业</li><li>学员供不应求</li></ul>
$("li").click(function(){$(this).css("color", "red");});
closest()、parent()和parents()方法
<div><p>武汉长乐教育<p><p>口碑超好的武汉PHP培训机构</p><p>您学会了吗?</p><span></span><a href="#">点我</a></div><div id="first"><p>一级目录</p><div><p>二级目录</p><div><p>三级目录</p><div><a href="#">点我</a></div></div></div></div>
$("a").click(function(){$(this).closest("div"); //一直向上找符合条件的元素,返回一条,如果自己符合就返回自己//$(this).closest("a");$(this).parent(); //返回父级元素,返回一条$(this).parents("div"); //获得集合中每个匹配的祖先元素,返回多个父节点});
find()方法
$("#first").find("a"); //一直往下级找,返回多个子孙节点
jQuery遍历节点的更多相关文章
- jQuery遍历节点方法汇总
1.children()方法:$('div').children()---遍历查找div元素的所有子元素节点 <p>Hello</p> <div> <span ...
- jquery遍历节点 children(),next(),prev(),siblings()closest() 等一些常用方法...
函数 描述 .add() 将元素添加到匹配元素的集合中. .andSelf() 把堆栈中之前的元素集添加到当前集合中. .children() 返回被选元素旗下的所有直接子元素 .closest() ...
- 7-20 jquery遍历节点,bootstrap模态框绑定事件和解绑,mock.js,model.urlroot,id,打基础
7-19 1:$(event.target).parents().filter("tr").find("host-name") 为什么选择不到别的host-na ...
- jQuery 遍历函数
转载http://www.cnblogs.com/tylerdonet/archive/2013/04/05/3000618.html jQuery 遍历函数包括了用于筛选.查找和串联元素的方法. 函 ...
- jQuery -- DOM节点的操作
DOM 操作的分类: dom core: getElementById() getElementsByTagName() getAttribute() setAttribute() html-dom ...
- jquery遍历
http://www.cnblogs.com/tylerdonet/archive/2013/04/05/3000618.html jQuery 遍历函数 jQuery 遍历函数包括了用于筛选.查找和 ...
- jQuery 遍历函数(w3school)
jQuery 遍历函数包括了用于筛选.查找和串联元素的方法. 函数 描述 .add() 将元素添加到匹配元素的集合中. .andSelf() 把堆栈中之前的元素集添加到当前集合中. .childr ...
- Jq_Ajax 操作函数跟JQuery 遍历函数跟JQuery数据操作函数
JQuery文档操作方法 jQuery 库拥有完整的 Ajax 兼容套件.其中的函数和方法允许我们在不刷新浏览器的情况下从服务器加载数据. 函数 ...
- JS获取与遍历节点的兄弟父级
发布:脚本学堂/JavaScript 编辑:JB01 2014-01-23 15:40:11 [大 中 小] 介绍下js获取节点的兄弟.父级与子元素的方法,学习下js遍历节点的操作方法,有需要 ...
随机推荐
- Java框架之搭建环境maven报错
*maven Dependencies 中的地址通过POM 才会增加 正确是 1. m2所在位置 遇到的问题: java.lang.ClassNotFoundException: org.spring ...
- codevs1068(dp)
题目链接: http://codevs.cn/problem/1068/ 题意: 中文题诶~ 思路: dp 用 dp[i][j][k][l] 表示取 i 个 1, j 个 2, k 个 3, l 个 ...
- django2集成DjangoUeditor富文本编辑器
富文本编辑器,在web开发中可以说是不可缺少的.django并没有自带富文本编辑器,因此我们需要自己集成,在这里推荐大家使用DjangoUeditor,因为DjangoUeditor封装了我们需要的一 ...
- Cocoapds pod install时报错 :The sandbox is not sync with the Podfile.lock
解决方法简单:仅供其他小伙伴参考 删除项目工程本地文件夹中的xxx.workspace和Podfile.lock文件,然后重新pod install即可
- Codeforces Round #305 (Div. 2) B
Description Mike and some bears are playing a game just for fun. Mike is the judge. All bears except ...
- Codeforces - 440C DFS
搜索苦手,注意正负 #include<bits/stdc++.h> #define rep(i,j,k) for(int i = j; i <=k; i++) using names ...
- UESTC 1437
LCA模板题 随便找的倍增模板... #include<bits/stdc++.h> using namespace std; const int maxn = 1e5+11; int t ...
- Django ORM 字段合集
AutoField(Field) - int自增列,必须填入参数 primary_key=True BigAutoField(AutoField) - bigint自增列,必须填入参数 primary ...
- Go语言基础之20--web编程框架之Gin框架
一.Gin框架介绍 1.1 简介 A. 基于httprouter开发的web框架. http://github.com/julienschmidt/httprouter B. 提供Martini风格的 ...
- MSF利用ms17-010漏洞过程记录
1.使用网上以上一个监测工具,扫描出存在ms17-010的主机地址 2.在kali中使用MSF进行检测,存在mf17-010漏洞 msf > use auxiliary/scanner/smb/ ...