jquery 지식 내부 외부 삽입 요소

1507 단어 jquery
<!doctype html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>    </title>

<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>    

<script type="text/javascript">

$(function(){

    $('#box ul li').append('<h3>    </h3>');//              

    $('#box ul').appendTo('div');//                      ,     div  

    $('#box ul li').prepend('<h3>     </h3>');//        

    $('#box ul li').prependTo('');//                     

    // after(content)//             

    // before(content)//             

    $('#box ul li').insertAfter('ol');//                          ,      

    $('#box ul li').insertBefore('ol');//                          ,      

})

</script>

<style type="text/css">

    #box{

        width:500px;

        height: 300px;

        margin:0 auto;

        border:1px solid green;

    }

    div{

        border:1px solid green;

    }

</style>

</head>

<body>

    <div id="box">

        <ul>

            <li>1</li>

            <li>2</li>

            <li>3</li>

        </ul>

    </div>

    <div></div>

    <ol></ol>

</body>

</html>


좋은 웹페이지 즐겨찾기