二、插入元素:

1 <div>
2 <p>面朝大海,春暖花开</p>
3 </div>

(一)、jQuery方法

1、在节点内部插入:

方法

说明

append()

向每个匹配的元素内部追加内容

appendTo()

把所有的元素追加到另一个指定的元素集合中,实际上是颠倒了append()的用法。如$(A).append(B)与$(B).appendto(A)是等价的

prepend()

向每个匹配的元素内部前置内容

prependTo()

把所有匹配的元素前置到另一个指定的元素集合中。实际上是颠倒了preprend()的用法。如$(A).prepend(B)与$(B).prenpendTo(B)等价

具体实现如下:

1 $("div").append("<p>这是append()方法添加的内容</p>");//在div元素下第一个子节点位置插入段落
2
3 $("div").prepend("<p>这是prepend()方法添加的内容</p>");//在div元素下最后一个子节点位置插入段落

下面这两种方法更符合人的一般思维,但效果是一样的

1 $("<p>这是appendTo方法添加的内容</p>").appendTo("div");//把段落插到div元素的第一个子节点位置
2
3 $("<p>这是prependTo方法添加的内容</p>").prependTo("div");//把段落插到div元素的最后一个子节点位置

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAATcAAAB0CAIAAABv++ITAAAXj0lEQVR4nO2d7VMUSZ7H/RfWFxNxt6+uX3CEc3NB7MUYMYEvHOIuLiYugsB5cI1jVh10x3CcYXFUxofx6FHHABeH8xyGccfFB2CVlmcE1HZ4GEUbeXDA5qFtQWx5aKABgYamqe7Ke5FuWVRmZWU/QYG/b2R0VGf9KrMyKz+ZVdn561qDQCCQvrVmuU8ABAJp6CWlY9M+CBAg6C0sovSKqfRs9o//+3/Z8nDu/IU7loecyT3vn85/P/9J2wj+6nR5K/dVV+6rdrq8y15UCBBWaFhE6a3au6mpXyUvVtaZsx3dTzmTA0ohQAh7WETpM+dUzl/+um/ffgnRr4/+T7W5fuTFguIw58R8ffXdB3c7FPEKSjnD6Auhruru/fq20RfCstcIBAh6C4soHZ0SHjzsTjMekyj968X8J44xxTGOoamqKzV1VXedE/M4pr974sp/Xz31xrE//+OJ7JgzmNJH5r70tcb0tcbqw7ew2dDw3NU/FD4y9+GvT9pG8hIuP3s8SU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lObm5koep9jlzWKxsIvDKD67ZvgteSilJqVGKc9FZPcy4AUOXuAILYkXOAqQUipLmkMfz4FS5bAtA6WUZy/PUdQY8AJXCrzAI+EFjghKW1paEhMTnz596vf76+rqNm/eLPc+5aFUreBsM/KTeqCuKMUCL/BXAi9wQwS8wBFBqSAIxcXFcXFxUVFRW7du7ejoUBRKrbCKbertIoOuQCklEyQj2WfIsGEUgXoseIG/lB481xQXW7MJss2oWhbPNR4xGnEoiciTYh/CAzl1m8G83IbNNvv85QIv8DAL/EtBSyOgNHgBpaClEVAKAoGWQUApCKR3AaUgkN4FlIJAelc4KR1octzYW+mb98kjFfNGPq/PfLDGfLDG5/XR0gCBQEqFjVK/4P/565uKhSAIKAWBQlYwlL5wTd4uujW2eDHkZN9ExafFioUgKNjfYES/eO9mo3wlMAj02ipgSp89flZ+ofSJ9YkivvX8A/lfWkw5XpRsKzz1xrHM33774+/OYEodd/vT1xrT1xrrjGZs5p3xln5ictztx19dPWPSEl+FhyoI9NoqMEq7WjrLL5SSK+MVf2nhmZgrTrzSa7aLftHtnLn6QZ58LG3Pa5MoRQh1FT+qP3Ybu+q2nn/QmPmL5HQvLAh3qhpuFtYofPNBoNdKAVDa3dpVdM7kfE55a1hX8SM5XYPNA5W7ShbcC4h2x6ugVCLcO+O9/lmp3DscIeT3+xsq66sLrs/OrKrVJCAQv8IwlnpnvFVflMs5dNztr/hjMfb6mx11F37IGksl/6MRq9P8VbV8ilhYEO7dbISxFPSaK5jn0rLcksftNilmoMlRZzRLf2mBEHrRP1nwXxdGOobnp+fNB2vOvX2WRSlCI1Zn/Te3W88/kDvdw3MpCIQV6hwv+ZcWCCEkoq4SK/57qK7iRzf2VmJK2/Pa8OyRYg7JN++7ffjGrQNV2GEXwRwvCCRTqL+Xjlid1z8rlegCgUBhF6wQBIH0LqAUBNK7KJSCQCBdCSgFgfSu/weoUqvLh2+HfAAAAABJRU5ErkJggg==" alt="" />

2、在节点外部插入:

方法

说明

after()

在每个匹配的元素之后插入内容

before()

在每个匹配的元素之前插入内容

insertAfter()

把所有匹配的元素插入到另一个指定的元素集合的后面

insertBefore()

把所有匹配的元素插入到另一个指定的元素集合的前面

具体实现如下:

1 $("div").after("<p>这是after()方法添加的内容</p>");//在div元素后面插入段落
2
3 $("div").before("<p>这是before()方法添加的内容</p>");//在div元素前面插入段落
1 $("<p>这是insertAfter方法添加的内容</p>").insertAfter("div");//把段落插入到div元素后面
2
3 $("<p>这是insertBefore方法添加的内</p>").insertBefore("div");//把段落插入到div元素前面

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVsAAABWCAIAAADuRKLQAAAak0lEQVR4nO2d/U8USf7H+Rv84ZLL/XT8YMjlciGXrL/gD575+t0ze9ldo1kvcePeArfqrQx4ooLAAoI87Kp8jYtINMPhyLE8w/AkD/KggIgCCw5PjrAjy8OgwyDz3DTT9f2hsG27qmtqhqcB6hVCpqurq6ur6/Pu6uqqTwUABoPBeEfAZmeAwWD4EUwRGAzGezZZEQIDAwmbsl0o65/BjYB8IfRFJEbwWEqURefDqX1IluFXbH4bgbLaoeHbqWLRiwKlhXulMpRxfFYErJpvP2XfHmy+IkA8VhRyBL1eHxoaOj8/T3/Gjo6OgwcPBgYGHjp0yKsDPdLT03Pr1q2lpSUAgNvtzs3N7ezslMXx2UgoFdMrRUDPi80MNns0lyBNgRxIQgCdVx4Olz2niszwFX9RBBloLSGHeKsIJpMpLCxsaGhoNZnEMjY29ve//31sbEwMMRqNJ0+elIZIobQHStWgMU50F2qcqOlijZnyt1LitFoAAADAOmOp/LrEOmOhP4ThA6tVBH6Jf9zYqeshKffc1Fxj8f23pgVZOPoIku5Sioyt6N4qgg9tCho4jouPj29paZGFt7e3nzt3zuFwoIeQrYJGGQlHKUWWRfCoCLJ0fFME7BmxzLyaaS5rsi5apYHDZc8fZz0CAuE4MPD458eNnfwST4rEILIqRbAuWhuK6rsaVu6Bw2SvCisd0PTlfnQj6/cZT28+dvNuGHO4d0ibXznzagZNhPw4okSv10dH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l2WRet9YV1WHuWLd45oOm7+acsQ/uEm3f35z17ENcgPmb4Jf5RbXtDUT1cB5ixJmwT/wiCINTU1Ozfvx9WO9EzEqBWBK/8I8zPz3/77bfYeYcAgMLCQtju8JhzwpWSC8HbRChFhEYRaO4XWdHsVntdQc3Dmna0ze80O6rCShcmzGLIgKZPXE/8zcjr6hPlnOV9/4Lb7W6vbqsrqLFb7UqFwPCKbeIfYWRk5G9/+9vQ0BBAJgvSKwK9fwQfFAFrt+TLpDxQLAePqXmlCDR7aY7Chii1Ecab9Y/SW6WTkaWKYByYrT1duWRbgpv8Et/V0MnaCGvLNvGP0N/f/9lnn01PT1sslszMzMOHD5MVoaWlJSIiQvoBwiv/CIS3BkEQ0tLSUHGhUQSlayRHQ/+jR/mbIoB3/QiNxffFfoRl13LThTrpmyYAYEDT1xx3X3ALS7al5th68YWC9SOsE9vEP4LD4cjIyAgKCjp48KBGo4mIiCArgs1mS0tLCwoKCnzXs+itfwRCz2J4eLjMxyGNLSk1gmStIaUflIqAtuGxZyHnkBCHcAnogbJvDdglEgY0fRm7kjJ2Jd0IuvL4/zp4Bw/Yt4b1hPlH8BH6r48Eg6E/HcEasbtk+oIGYlNGi5qcBxodIedfRGmJBOlbA2MDYLOhfQQ7QmlsbOz06dNKI5QYPsAUYYNhiuA7PM/n5OSI6zK5XK7MzEx0FDNjNTBF2GD8dBQzg8HYFJgiMBiM9zBFYDAY7/l/3EnkAspNw6IAAAAASUVORK5CYII=" alt="" />

 

3、appendTo(),prependTo(), insertBefore(),insertAfter() 方法具有破坏性操作特性,也就是如果选择已经存在内容,并把它们插入到指定对象中时,则原位置的内容将被删除。下面实例中将原div元素中包含的段落文本选中并移到div元素后面。演示如下:

1 $("p").insertAfter("div");

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMQAAAAlCAIAAACS3NEbAAAJEklEQVR4nO2b208bVx7H+zf0YaV9XJ72YbUPK61kdaVEQqpW7XYftm3SqpVaUVZZ7XajhFbbXacQYAs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P9z5VcPu6DYGWSwae6R+qFU8iBxH2EaBg9hgAp0eda9yc8mAJFNsR8Bw79sd09/cfw5FAkcB2cV7wLYLj7dbjpRdip31J8RGqGOdtoRwIYAUQxvAPvfEMJZBoM2Q1kNMib1f6iFta1wITiQSq7MrE3fHqMvCwYOn2nIN/rSDRk/rb5r0jbp4JA78zzn0YR++/CFJZEO3PtarAp0eLkPBJEaYILd3tFNuWNggOiNgWHbxHmj0oCiKIuhsxfS+Zo8Y4HhmH2mT7a7v4B4qE0wwkUaKafqJ17JzkHb6Uc4wcUGTmhLHzNlzYGkwmUyuzq4ou0aDPvKuKBFNTJWNHa0c4h7Q6JFdvBcBwyiKwsfwxN+Vri0n8ZKN+fXRTjnk9jJlklYnrkw4TMl4cuaf95/NmfF4h9Wh7lVmVpmonpOGUcWOL5cWiAFMaZAap73fjG8hbSRTZQK2XZNX1HAYxj1EmGLB2NhfFJ5dN3YKSSKbS4ZxqTpflQkTtmfSTTzC90xDH/YB2y4UQW3Lh8RSmc2eif2hz2AmqLWNaV7TkkSMTNsU7qTljLZfUjvs6TFlu7P+RNmlsFuOUscIulQ/f/DgKTEGNHoGP+g7doWQJGJU7ahKR2KhGFqwPRMm4tsctmeqe7NK9LN/D37Q5zSk0Mn+bQ4Ppn5OO6Dc+eCODpdrafulwsGOO8r6bHC/NeLbnM8MqUpHnkMvwQEaPeJfN9a9WfX9z2tUpSOBw9Q/FBXubY6kl/ZM3HSiqaUCRCpRTK2xnOIYkFZcHgZqMFPvTFWNBSxaD63WO1fXO1dJTuIylyflHSZeZ0Q8TLxypjMHEy9eLOJh4pUz8TDxypn+D/F3vV/0rtR/AAAAAElFTkSuQmCC" alt="" />

 

(二)、JavaScript方法

1、在节点内部插入:appendChild()—--对应于jQuery的append(), insertBefore()---对应于jQuery中的prepend()

     具体效果请看上面jQuery方法。。。

2、自定义JavaScript扩展DOM功能函数================待续~待续~待续

节点插入--对比jQuery和JavaScript方法(一)的更多相关文章

  1. 节点的创建--对比jQuery与JavaScript 方法

    一.  创建节点: 节点是DOM结构的基础,根据DOM规范,节点是一个很宽泛的概念,包含元素.属性.文本.文档和注释.但在实际开发中,要动态创建内容,主要操作的节点包括元素.属性和文本. 1.需求:创 ...

  2. 对比JQuery与JavaScript

    JavaScript 是一种脚本语言,主要用在浏览器中,实现对网页的文档对象的操作和一些用户交互动作的处理.而 jQuery 则是 JavaScript 的一个代码库(或习惯性叫类库),它将一些在 J ...

  3. jquery调用javascript方法

    本来想找个“优雅”一点的方法,类似C#在调用C++方法时候的Invoke之类的.没找到,后来想想,其实也没必要,直接写就好了,算最优雅了吧.只是少了VS的Intelligence,有点不习惯罢了. 事 ...

  4. jQuery:节点(插入,复制,替换,删除)操作

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  5. Query节点操作,jQuery插入节点,jQuery删除节点,jQuery Dom操作

    一.创建节点 var box = $('<div>节点</div>'); //创建一个节点,或者var box = "<div>节点</div> ...

  6. jQuery节点操作,jQuery插入节点,jQuery删除节点,jQuery Dom操作

    一.创建节点 1 var box = $('<div>节点</div>'); //创建一个节点,或者var box = "<div>节点</div& ...

  7. 手写面试编程题- 数组去重 深拷贝 获取文本节点 设置奇数偶数背景色 JS中检测变量为string类型的方法 第6题闭包 将两个数组合并为一个数组 怎样添加、移除、移动、复制、创建和查找节点? 继承 对一个数组实现随机排序 让元素水平 垂直居中的三种方式 通过jQuery的extend方法实现深拷贝

    第1题==>实现数组去重 通过 new Set(数组名) // var arr = [12, 12, 3, 4, 5, 4, 5, 6, 6]; // var newarr1 = new Set ...

  8. Jquery源码中的Javascript基础知识(四)— jQuery.fn.init方法

    $() 即调用了jQuery.fn.init方法 jQuery = function( selector, context ) { return new jQuery.fn.init( selecto ...

  9. 使用jquery的load方法设计动态加载,并解决被加载页面JavaScript失效问题

    一.问题分析 对于后台系统,相比大家都有所印象,知道其中的布局结构,如图: 在这种布局中我们需要将header,sidebar,footer分开,而且对于中间部分的content内容需要动态变化,即根 ...

随机推荐

  1. linux驱动程序之电源管理之标准linux休眠与唤醒机制分析(一)

    1. Based on linux2.6.32,  only for mem(SDR) 2. 有兴趣请先参考阅读: 电源管理方案APM和ACPI比较.doc Linux系统的休眠与唤醒简介.doc 3 ...

  2. 【Java基础】List迭代并修改时出现的ConcurrentModificationException问题

    现在有一个需求,要遍历一个List,假设List里面存储的是String对象,然后该需求事判断里面如果有某个对象,则添加一个新的对象进去.自然,我们得出下面的代码: import java.util. ...

  3. 问题-[Delphi]无法设置断点

    问题现象: 今天突然发现不知何时起DELPHI7除了.dpr文件外,其余各Unit都无法设置断点.即在设计状态下设置了断点,在运行后出现的无效断点!百思不得其解...后查了许多资料,花了两个小时才搞好 ...

  4. poj 3469 Dual Core CPU【求最小割容量】

    Dual Core CPU Time Limit: 15000MS   Memory Limit: 131072K Total Submissions: 21453   Accepted: 9297 ...

  5. 利用ACE 自己实现的线程池

    1: 线程池组件的配置文件: [log] ;DEBUG = 0 ;INFO = 1 ;WARN = 2 ;FAULT = 3 level=0 ;SCREENOUT = 0 ;FILEOUT = 1 ; ...

  6. CSS3最简洁的轮播图

    <!DOCTYPE html> <html> <head> <title>CSS3最简洁的轮播图</title> <style> ...

  7. 【JAVA - SSM】之MyBatis查询缓存

    为了减轻数据压力,提高数据库的性能,我们往往会需要使用缓存.MyBatis为我们提供了一级缓存和二级缓存. (1)一级缓存是SqlSession级别的缓存,在操作数据库的时候需要创建一个SqlSess ...

  8. Android多语言支持以及各国语言Values文件夹命名规则

    创建好的项目工程由于需求 需要做多国语言的支持  下面介绍怎么快捷的创建文件夹 建好一个android 的项目后,默认的res下面 有layout.values.drawable等目录 这些都是程序默 ...

  9. iOS开发之地图代理不起作用(提示vImage decode failed, falling back to CG path.)

    项目中用到了地图相关的东西,就把曾经的demo搬了出来,结果发现直接执行之前的demo没有问题,在xcode5下新建项目再把代码粘贴过来就会提示 May 5 11:36:21 infomedia-iP ...

  10. Android音频底层调试-基于tinyalsa

    因为Android中默认并没有使用标准alsa,而是使用的是tinyalsa.所以就算基于命令行的測试也要使用libtinyalsa.Android系统在上层Audio千变万化的时候,能够能这些个工具 ...