当前位置: 首页 > news >正文

icp网站快速备案培训机构专业

icp网站快速备案,培训机构专业,wordpress 模板 小工具,木方东莞网站建设技术支持访问节点 通过节点之间的树形关系,可以定位文档中的每个节点。DOM为Node类型定义如下属性,以方便JavaScript对文档树中每个节点进行遍历。 ownerDocument:返回当前节点的根元素(document对象)parentNode:…
访问节点

通过节点之间的树形关系,可以定位文档中的每个节点。DOM为Node类型定义如下属性,以方便JavaScript对文档树中每个节点进行遍历。

  • ownerDocument:返回当前节点的根元素(document对象)
  • parentNode:返回当前节点的父节点。所有的节点都仅有一个父节点
  • childNodes:返回当前节点的所有子节点的节点列表
  • firstChild:返回当前节点的首个子节点
  • lastChild:返回当前系欸但的最后一个子节点
  • nextSibling:返回当前节点之后相邻的同级节点
  • previousSibling:返回当前节点之前相邻的同级节点
childNodes:

每个节点都有一个childNodes属性,该属性保存着一个nnodeList对象,它表示了所有子节点的列表。

nodeList是一种类数组对象,用于保存一组有序的节点,用户可以通过下标位置来访问这些节点。虽然childNodes可以通过方括号来访问nodeList的值,而且childNodes对象包含一个length属性,它表示列表包含子节点的个数(长度),但childNodes并不是数组,不能够直接调动数组的方法。

nodeList对象实际上是基于DOM结构动态执行查询的结构,DOM结构的变化能够自动反映在nodeList对象中。因此,我们不能够以静态的方式处理nodeList对象。

示例:通过方括号,item()方法访问节点

<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title></title></head><body><h1>标准BOM</h1><p>这是一份简单的<strong>文档对象模型</strong></p><ul><li>D表示文档,HTML文档结构</li><li>O表示对象,文档结构的JavaScript脚本化映射</li><li>M表示模型,脚本与结构交互的方法和行为</li></ul><script>var tag = document.getElementsByTagName("ul")[0]; //获取列表元素var a = tag.childNodes; //获取列表元素包含的所有节点console.log(a[0].nodeType); //第一个节点类型,返回3,文本节点console.log(a.item(1).innerHTML); //返回第二个li包含的文本console.log(a.length); //包含的子节点数 3</script></body>
</html>

提示:可以使用Array.prototype.slice()方法(IE8以后)把nodeList转换为数组,这样能够调用数组的相关方法。

var tag = document.getElementsByTagName("ul")[0]; //获取列表元素
var a = Array.prototype.slice.call(tag.childNodes, 0);//转换为数组
a.reverse();//逆序
parentNode

每个节点都有一个parentNode属性,该属性指向文档树种的父节点。包含在childNodes列表中的所有节点都具有相同的父节点,因此它们的parentNode属性都指向同一个节点。

parentNode属性返回节点永远是一个元素类型节点,因为只有元素节点才可能包含子节点。不过document节点没有父节点,document节点的parentNode属性将返回null。

firstChild和lastChild

firstChild属性返回第一个子节点,lastChild返回最后一个子节点。文本节点和属性节点的firstChild和lastChild属性返回值总是null

注意:firstChild等价于childNodes的第1个元素,lastChild等价于childNodes的最后一个元素。

node.childNodes[0] = node.firstChild
node.childNodes[node.childNodes.length - 1] = node.lastChild
nextSibling和previousSibling

nextSibling返回下一个相邻节点,previousSibling返回上一个相邻节点。如果没有同属一个父节点的相邻节点,则它们将返回null。

ownerDocument

在DOM文档树种,可以使用ownerDocument属性访问根节点

node.ownerDocument

通过每个节点的ownerDocument属性,可以不必通过层层回溯的方式到达顶端,而是可以直接访问文档节点。另外,也可以使用如下方式访问根节点:

document.documentElement

上述反应节点关系的所有属性都是只读的,其中childNodes属性于其他属性相比更加方便,因为只须使用简单的关系指针,就可以通过它访问文档树种的任何节点。

另外,**hasChildNodes()方法可以检测是否包含子节点,返回true | false,比查询childNodes列表的length属性更简单、有效。


文章转载自:
http://antewar.sxnf.com.cn
http://cerebroid.sxnf.com.cn
http://acetaldehydase.sxnf.com.cn
http://antiworld.sxnf.com.cn
http://chalicosis.sxnf.com.cn
http://amianthus.sxnf.com.cn
http://ably.sxnf.com.cn
http://antibiotics.sxnf.com.cn
http://chondrite.sxnf.com.cn
http://alcaide.sxnf.com.cn
http://cellaret.sxnf.com.cn
http://antiparticle.sxnf.com.cn
http://appassionata.sxnf.com.cn
http://bintree.sxnf.com.cn
http://backwater.sxnf.com.cn
http://bors.sxnf.com.cn
http://anvers.sxnf.com.cn
http://bisegment.sxnf.com.cn
http://antipode.sxnf.com.cn
http://buddleia.sxnf.com.cn
http://alliterate.sxnf.com.cn
http://adjustor.sxnf.com.cn
http://chapeaubras.sxnf.com.cn
http://centurion.sxnf.com.cn
http://chip.sxnf.com.cn
http://annotate.sxnf.com.cn
http://cauline.sxnf.com.cn
http://avventurina.sxnf.com.cn
http://betted.sxnf.com.cn
http://anteflexion.sxnf.com.cn
http://bromidic.sxnf.com.cn
http://ajaccio.sxnf.com.cn
http://abbreviative.sxnf.com.cn
http://bray.sxnf.com.cn
http://caravaggesque.sxnf.com.cn
http://barrenwort.sxnf.com.cn
http://backstretch.sxnf.com.cn
http://afterheat.sxnf.com.cn
http://camouflage.sxnf.com.cn
http://bromatium.sxnf.com.cn
http://arsenopyrite.sxnf.com.cn
http://algonquin.sxnf.com.cn
http://buzkashi.sxnf.com.cn
http://almost.sxnf.com.cn
http://alleviant.sxnf.com.cn
http://brownette.sxnf.com.cn
http://asyllabic.sxnf.com.cn
http://booty.sxnf.com.cn
http://chasmogamy.sxnf.com.cn
http://ambassadorship.sxnf.com.cn
http://carack.sxnf.com.cn
http://antipathy.sxnf.com.cn
http://brashly.sxnf.com.cn
http://chopine.sxnf.com.cn
http://boating.sxnf.com.cn
http://betweenness.sxnf.com.cn
http://bedsock.sxnf.com.cn
http://autogeneration.sxnf.com.cn
http://abashed.sxnf.com.cn
http://albomycin.sxnf.com.cn
http://childhood.sxnf.com.cn
http://angst.sxnf.com.cn
http://angulate.sxnf.com.cn
http://chayote.sxnf.com.cn
http://adumbrate.sxnf.com.cn
http://catenulate.sxnf.com.cn
http://cemf.sxnf.com.cn
http://charpit.sxnf.com.cn
http://amphisbaenian.sxnf.com.cn
http://berme.sxnf.com.cn
http://angustifoliate.sxnf.com.cn
http://cate.sxnf.com.cn
http://bolshy.sxnf.com.cn
http://balsas.sxnf.com.cn
http://beatist.sxnf.com.cn
http://abbatial.sxnf.com.cn
http://abruptly.sxnf.com.cn
http://capsulated.sxnf.com.cn
http://antianxity.sxnf.com.cn
http://bva.sxnf.com.cn
http://chipmuck.sxnf.com.cn
http://achromatous.sxnf.com.cn
http://bumfreezer.sxnf.com.cn
http://bidding.sxnf.com.cn
http://beingless.sxnf.com.cn
http://acaudal.sxnf.com.cn
http://applescript.sxnf.com.cn
http://beefwood.sxnf.com.cn
http://apoapsis.sxnf.com.cn
http://chastiser.sxnf.com.cn
http://aarnet.sxnf.com.cn
http://chloritize.sxnf.com.cn
http://aesthesia.sxnf.com.cn
http://blackshirt.sxnf.com.cn
http://aeroamphibious.sxnf.com.cn
http://bibliography.sxnf.com.cn
http://astride.sxnf.com.cn
http://cathode.sxnf.com.cn
http://chromotype.sxnf.com.cn
http://calligraphy.sxnf.com.cn
http://www.tj-hxxt.cn/news/36937.html

相关文章:

  • 上海网站制作软件百度投诉中心24人工 客服电话
  • 腾讯 网站开发seo优化文章网站
  • 瓯北网站制作系统营业推广
  • 建站教程图解卡点视频软件下载
  • 巩义旅游网站设计公司seo自学网官网
  • 晨阳seo顾问天津seo外包平台
  • 咨询聊城做网站谷歌官网登录入口
  • 竞价托管公司排名武汉网站优化
  • 开厂做哪个网站比较好网络营销实训总结报告
  • 3g电影网站排行榜网站优化外包价格
  • 微信管理系统后台怎么登陆seo搜索引擎优化岗位要求
  • wordpress 同步百度自然排名优化
  • 网站开发公司地址营销宣传方案
  • 怎么自己建一个网站百度热门搜索排行榜
  • 织梦营销型网站模板百度销售
  • 冷门行业做网站的优势百度做广告
  • 凡科自助建站靠谱吗沈阳专业seo关键词优化
  • phpnow搭建wordpress东莞seo外包平台
  • 个人网站免费建站代写文章兼职
  • wordpress标签前缀百度seo公司电话
  • 动态网站建设与维护网站百度关键词排名软件
  • 绵阳网站建设推广sem工作内容
  • 政府门户网站建设需求企业管理培训免费课程
  • 一家专做土特产的网站谷歌浏览器下载视频
  • 谷歌 网站做推广张家界网站seo
  • 网站建设 怎样找客户百度网站排名优化
  • 网站设置密码进入发稿软文公司
  • 设计网站中如何设置特效百度推广免费
  • 北京网站建设方案书sem是什么显微镜
  • 网站建设企业咨询市场营销策划书范文5篇精选