append、appendTo、prepend、prependTo 比较

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Jquery test1</title>
    <script src="js/jquery1.42.min.js"></script>
    <script>
        $(function(){
            
        
            //append appendTo preappend preappendTo  比较
        
            //append(content|fn)
            //appendTo(content)
            //prepend(content)
            //prependTo(content)
            
            //$(".test1").append("我是插入的内容~");//append 插入到内容中的最后
            
            //$(".test-span0").appendTo(".test1");//appendTo 插入到内容中的最后
            
            //$(".test-span0").prepend("<em>我是插入的内容~</em>"); //插到内容的前面 
            
            //$(".test-span0").prependTo(".test1");  //插到内容前面
            
            
        
            
        });
    
    </script>
</head>
<body>
    <span class="test-span0"></span>
    <div class="test1">
        <span class="test-span1">111</span>
        <span class="test-span2">222</span>
        <span class="test-span3">333</span>
    </div>
    
    
</body>
</html>

  

posted @ 2015-05-18 15:06  前端小晖  阅读(477)  评论(0)    收藏  举报