分享

【JS--Jquery】--append() 和appendTo()用法

 心情谷 2014-03-13
    

       

append()

1.create content

  1. <h2>Greetings</h2>  
  2. <div class="container">  
  3.   <div class="inner">Hello</div>  
  4.   <div class="inner">Goodbye</div>  
  5. </div>  
2.select an element on the page and insert it into another:(注意是move,而不是cloned)

  1. $('.container').append($('h2'));  
  2. //<h2>Greetings</h2>被移动到下方去了  


3.additional arguments--with functions
$(selector).append(function(index,html))
index - 可选。接收选择器的 index 位置。
html - 可选。接收选择器的当前 HTML。
appendTo()
$(content).appendTo(selector)


4.比较:
append() 和 appendTo() 方法执行的任务相同。不同之处在于:内容和选择器的位置,以及 append() 能够使用函数来附加内容





  1. <pre></pre>  
  2. <pre></pre>  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多