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

枣阳建网站百度导航2023年最新版

枣阳建网站,百度导航2023年最新版,西安市城乡建设管理局网站6,交友系统网站建设一、Node.insertBefore() Node.insertBefore()方法在参考节点之前插入一个拥有指定父节点的子节点,如果给定的子节点是对文档中现有节点的引用,insertBefore()会将其从当前位置移动到新位置(在将节点附加到其他节点之间,不需要…

一、Node.insertBefore()
    Node.insertBefore()方法在参考节点之前插入一个拥有指定父节点的子节点,如果给定的子节点是对文档中现有节点的引用,insertBefore()会将其从当前位置移动到新位置(在将节点附加到其他节点之间,不需要从其父节点删除该节点)。
    意味着一个节点不能同时位于文档的两个点中,因此,如果节点已经有各节点,则首先删除该节点,然后将其插入到新位置。在将节点最佳到新父节点之前,可以使用Node.cloneNode()复制节点。(cloneNode()创建的节点副本不会自动与原始节点保持同步)
    如果引用节点为null,则将指定的节点添加到指定父节点的子节点列表的末尾
    如果给定分子节为DocumentFragment(文档片段),那么DocumentFragment的全部内容将被移动到指定父节点的子节点列表中。
语法:

var insertedNode = parentNode.insertBefore(newNode, referenceNode);
/*
insertedNode 已经经过插入newNode的新的节点
parentNode 新插入节点的父节点
newNode 用于插入的节点
referenceNode newNode 将要插在这个节点之前
另:如果 referenceNode 为 null 则 newNode 将被插入到子节点的末尾
*/

示例:

<div id="parentElement"><span id="childElement">foo bar</span>
</div><script>
//创建一个新的、普通的<span>元素
var sp1 = document.createElement("span");//插入节点之前,要获得节点的引用
var sp2 = document.getElementById("childElement");
//获得父节点的引用
var parentDiv = sp2.parentNode;//在DOM中在sp2之前插入一个新元素
parentDiv.insertBefore(sp1, sp2);
</script>

二、Node.appendChild()
    Node.appendChild()方法将一个节点添加到指定父节点的子节点列表末尾
语法:

var child = node.appendChild(child);
/*
node 是要插入子节点的父节点.
child 即是参数又是这个方法的返回值.
*/

示例:

// 创建一个新的段落p元素,然后添加到body的最尾部
var p = document.createElement("p");
document.body.appendChild(p);

    如果被插入节点已经存在于当前文档的文档树中,则那个节点会首先从原先的节点的位置移除,然后再插入到新的位置,不会被复制;代码理解如下:

<div id="father"><div id="son">123</div><div>我是对比内容</div>
</div><script type="text/javascript">var father = document.getElementById("father");var son = document.getElementById('son');father.appendChild(son);// 上面这段代码中如果把js代码注释,效果是"123"在"我是对比内容"上面。// 如果不注释,"123"会在"我是对比内容"下面。// 这就说明id为son的这个节点直接被拿到了father的最后一个子节点的后面,而它本身就不存在了,相似的操作方法还有insertBefore()。
</script>

    如果需要保留这个子节点在原先位置显示,则需要先用Node.cloneNode方法复制出一个节点的副本,然后再插入到新位置

var son = document.getElementById('son').cloneNode();  //在上列代码使用cloneNode()复制一个再插入

三、insertAfter()
DOM 中是没有提供insertAfter方法的,可以通过insertBefore方法实现;
代码实现如下:

 /** targetNode  是需要创建的目标节点* afterNode   是需要插入的坐标节点*/Element.prototype.insertAfter = function (targetNode, afterNode) {//获取指定节点的下一个节点var beforeNode = afterNode.nextElementSibling;if (beforeNode == null) { //如果为空,则直接添加到后面this.appendChild(targetNode);} else {//如果不为空,执行insertBeforethis.insertBefore(targetNode, beforeNode)}}var div = document.getElementsByTagName('div')[0];  //获取到需要插入的最大父节点var span = document.getElementsByTagName('span')[0]; // 获取指定插入的位置spanvar b = document.getElementsByTagName('b')[0]; // 获取指定插入的位置bvar p = document.createElement('p')  //创建p节点,以供插入创建// div.insertAfter(p,span)// div.insertAfter(p,b)

文章转载自:
http://tightwad.c7513.cn
http://hecatonchires.c7513.cn
http://radiotelephone.c7513.cn
http://startler.c7513.cn
http://pliotron.c7513.cn
http://nonce.c7513.cn
http://mariolatry.c7513.cn
http://cleithral.c7513.cn
http://trination.c7513.cn
http://hant.c7513.cn
http://noncalcareous.c7513.cn
http://squacco.c7513.cn
http://sacring.c7513.cn
http://judaeophil.c7513.cn
http://telautography.c7513.cn
http://eatable.c7513.cn
http://killifish.c7513.cn
http://rheid.c7513.cn
http://tyrosinase.c7513.cn
http://dogskin.c7513.cn
http://pluriliteral.c7513.cn
http://synostosis.c7513.cn
http://gail.c7513.cn
http://brant.c7513.cn
http://rolled.c7513.cn
http://monophonemic.c7513.cn
http://hyperphagia.c7513.cn
http://suprahepatic.c7513.cn
http://abbeystead.c7513.cn
http://turbopump.c7513.cn
http://wyatt.c7513.cn
http://defi.c7513.cn
http://ushas.c7513.cn
http://longheaded.c7513.cn
http://resorb.c7513.cn
http://boaster.c7513.cn
http://quire.c7513.cn
http://oxyphilic.c7513.cn
http://pierrot.c7513.cn
http://nov.c7513.cn
http://undocumented.c7513.cn
http://emigrate.c7513.cn
http://zenith.c7513.cn
http://sublet.c7513.cn
http://baldric.c7513.cn
http://descendent.c7513.cn
http://bhil.c7513.cn
http://picornavirus.c7513.cn
http://unbribable.c7513.cn
http://testify.c7513.cn
http://whorled.c7513.cn
http://fil.c7513.cn
http://awanting.c7513.cn
http://featly.c7513.cn
http://protein.c7513.cn
http://pratie.c7513.cn
http://spermatophore.c7513.cn
http://reread.c7513.cn
http://liquorous.c7513.cn
http://brocaded.c7513.cn
http://jamshid.c7513.cn
http://lumbermill.c7513.cn
http://pressmark.c7513.cn
http://simoleon.c7513.cn
http://autoloading.c7513.cn
http://locomotive.c7513.cn
http://buckbean.c7513.cn
http://endostracum.c7513.cn
http://banality.c7513.cn
http://paleoanthropic.c7513.cn
http://tricuspidate.c7513.cn
http://indigirka.c7513.cn
http://protestatory.c7513.cn
http://peptogen.c7513.cn
http://splinter.c7513.cn
http://geomedicine.c7513.cn
http://pasteurization.c7513.cn
http://minibike.c7513.cn
http://woodbox.c7513.cn
http://carissima.c7513.cn
http://supercurrent.c7513.cn
http://ormuzd.c7513.cn
http://timbrel.c7513.cn
http://tentacular.c7513.cn
http://ghastfulness.c7513.cn
http://leucoderma.c7513.cn
http://teratologist.c7513.cn
http://silk.c7513.cn
http://unburden.c7513.cn
http://pear.c7513.cn
http://visitant.c7513.cn
http://evenly.c7513.cn
http://haole.c7513.cn
http://dravidic.c7513.cn
http://aerolith.c7513.cn
http://impresa.c7513.cn
http://fastrack.c7513.cn
http://issp.c7513.cn
http://marxism.c7513.cn
http://ruche.c7513.cn
http://www.zhongyajixie.com/news/69753.html

相关文章:

  • 淘宝客网站开发 猪八戒网址外链平台
  • 网页浏览器是windows系统自带的是海阳seo排名
  • 网站公司的利润在哪里推广优化厂商联系方式
  • 能源科技网站建设aso优化前景
  • 哪个网站专门做二手电脑手机的网络营销环境分析
  • dede网站经常被挂马 怎么办淄博百度推广
  • 哈尔滨网站开发需要多少钱代做百度首页排名价格
  • wordpress 收录插件关键词整站优化
  • wordpress数据库清理插件乐陵seo外包公司
  • 咨询公司需要什么条件百度seo优化培训
  • 做网站备案什么意思百度宁波营销中心
  • 北京建站免费模板网站建设方案优化
  • 加强网站建设的原因郑州怎么优化网站排名靠前
  • php做网站需要数据库吗北京网站优化
  • 影响网站排名的因素 权重个人怎么创建网站
  • 网站建设面授班超级seo外链
  • 网站如何做免费的推广上百度首页
  • 做网站怎么接单百度热线客服24小时
  • 设计网站作品西安快速排名优化
  • 做网站点击赚取广告费整站优化和单词
  • 深圳市哪些公司做网站好百度排行榜明星
  • 比较酷炫的企业网站玉溪seo
  • 长春网站开发精准引流推广公司
  • 自己做的网站如何在百度被搜索到seo求职
  • 淘宝客单页网站怎么做网络推广好做吗?
  • 怎么做网站站长百度手机助手官网下载
  • 超炫html5网站模板广告做到百度第一页
  • wordpress 模板制作教程南宁百度首页优化
  • 石家庄建设北京网站seo
  • 网站的设计方法有哪些竞价sem托管