zoukankan      html  css  js  c++  java
  • [ jquery 文档处理 prependTo(content) ] 此方法用于把所有匹配的元素前置到另一个、指定的元素元素集合中

    把所有匹配的元素前置到另一个、指定的元素元素集合中

    实际上,使用这个方法是颠倒了常规的$(A).prepend(B)的操作,即不是把B前置到A中,而是把A前置到B中

    在jQuery 1.3.2中,appendTo, prependTo, insertBefore, insertAfter, 和 replaceAll这个几个方法成为一个破坏性操作,要选择先前选中的元素,需要使用end()方法,参见 appendTo 方法的例二

    实例:

    <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(){
            /*
                演示:破坏性操作和 prepend 和  prependTo 之间的区别
            */
            $('.active').prependTo($('#append'));
            $('.active').prepend('Some text and bold!');
        });
    </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 value :</li>
                    <li>Index value :</li>
                    <li>Index value :</li>
                </ul>
                <div id='append'></div>
            </div>
        </div>
    </body>
    </html>
  • 相关阅读:
    网页性能优化,缓存优化、加载时优化、动画优化--摘抄
    display的32种写法--摘抄
    transform与position:fixed的那些恩怨--摘抄
    float 常见用法与问题--摘抄
    10个JavaScript难点--摘抄
    CSS3 动画卡顿性能优化解决方案--摘抄
    CSS 盒模型、解决方案、BFC 原理讲解--摘抄
    web实时长图实践--摘抄
    移动端H5多平台分享实践--摘抄
    canvas绘制视频封面--摘抄
  • 原文地址:https://www.cnblogs.com/mysearchblog/p/5618165.html
Copyright © 2011-2022 走看看