zoukankan      html  css  js  c++  java
  • wrap添加及去除外层dom的方法

    Wrap an HTML structure around each element in the set of matched elements. .wrap()
    Wrap an HTML structure around all elements in the set of matched elements. .wrapAll()
    Wrap an HTML structure around the content of each element in the set of matched elements. .wrapInner()
    Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place. .unwrap()

                <div class="container">
                    <div class="inner">Hello</div>
                    <div class="inner">Goodbye</div>
                </div>
                $('.inner').wrap('<div class="new" />');
                <div class="container">
                    <div class="new">
                        <div class="inner">Hello</div>
                    </div>
                    <div class="new">
                        <div class="inner">Goodbye</div>
                    </div>
                </div>
    
                <div class="container">
                    <div class="inner">Hello</div>
                    <div class="inner">Goodbye</div>
                </div>
                $('.inner').wrapAll('<div class="new" />');
                <div class="container">
                    <div class="new">
                        <div class="inner">Hello</div>
                        <div class="inner">Goodbye</div>
                    </div>
                </div>
    
    
                <div class="container">
                    <div class="inner">Hello</div>
                    <div class="inner">Goodbye</div>
                </div>
                $('.inner').wrapInner('<div class="new" />');
                <div class="container">
                    <div class="inner">
                        <div class="new">Hello</div>
                    </div>
                    <div class="inner">
                        <div class="new">Goodbye</div>
                    </div>
                </div>
    

      

  • 相关阅读:
    【Scrum】2.18
    【scrum】2.22
    绿色软件 Vs 安装软件
    【Scrum】2.21
    【scrum】2.15
    读《design pattern》有感
    让广告再播一会儿~
    Qt::日志处理
    终于在博客园开通了
    惹毛程序员的十件事
  • 原文地址:https://www.cnblogs.com/longze/p/3029960.html
Copyright © 2011-2022 走看看