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>
    

      

  • 相关阅读:
    Flutter-仿ios底部彈出框
    Flutter-SingleChildScrollView
    stm32之IIC通信协议
    docker swarm搭建tidb踩坑日记
    剑指offer-机器人的运动范围
    beego跨域请求配置
    SQLAlchemy并发写入引发的思考
    关于docker线上部署时间问题
    设计模式
    leetcode刷题笔记258 各位相加
  • 原文地址:https://www.cnblogs.com/longze/p/3029960.html
Copyright © 2011-2022 走看看