zoukankan      html  css  js  c++  java
  • [ jquery 文档处理 wrap(html|element|fn) ] 此方法用于把所有匹配的元素用其他元素的结构化标记包裹起来

    此方法用于把所有匹配的元素用其他元素的结构化标记包裹起来

    实例:

    <html lang='zh-cn'>
    <head>
    <title>Insert you title</title>
    <meta http-equiv='description' content='this is my page'>
    <meta http-equiv='keywords' content='keyword1,keyword2,keyword3'>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
    <style type="text/css">
        *{margin:0;padding:0;}
        html{font:400 15px/1.2em 'Courier New';color:#666;750px;margin:25px auto;}
        ul{list-style:none;}
        .hover{color:#FF96EC;}
    </style>
    <script type='text/javascript'>
        $(function(){
            $('.active').wrap(function(index){  // 添加包裹机制
                return '<div class='+$(this).html()+'></div>';
            });
            $('p').unwrap();    //  取消包裹
        });
    </script>
    </head>
    <body>
        <div id='demo'>
            <div class='noClassDemo'>
                <ul class='list'>
                    <li>Index value :</li>
                    <li>Index value :</li>
                    <li>Index value :</li>
                    <li>Index value :</li>
                    <li>Index value :</li>
                    <li>Index value :</li>
                    <li class='active'>Index</li>
                    <li class='wrap'>Index value :</li>
                    <li>Index value :</li>
                </ul>
                <div class='unwrap'>
                    <p>this is unwrap test</p>
                </div>
            </div>
        </div>
    </body>
    </html>
  • 相关阅读:
    bzoj1505 [NOI2004]小H的小屋
    最大值
    数学
    OI中的快速傅里叶变换(FFT)
    旅游规划
    加分二叉树
    浅谈 字符串hash
    二分的弟弟“三分”
    Trie树(c++)
    克鲁斯卡尔
  • 原文地址:https://www.cnblogs.com/mysearchblog/p/5618404.html
Copyright © 2011-2022 走看看