亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

jQuery DOM ?? ??()

????? ??? ????? ???? ??? ??? ???? ???? ???? ?? ??? ?? ?? ??? ??? ??? ???? ????? ??? ??? ??? ? ????. ?? ??

detach ? ??? ???? ????. ? ??? ?????. ?, ??? ?? ????? ????? ? ??? ??? ?? ??? ?????.

jquery ?? ??? ??? ???????.

? ???? jQuery ???? ???? ??? ???? ???? ??? ???? ??? ??? ?? ??? ? ????. ??()? ?? ?? ???? ???, ??? ??? ?? ?????.
$("div").detach()? ??? ????? ?? ??? ?????. ??? ??? ??? ?? ?? ????. ???? ?? ???? ?????. ?? ??????.

?? ??? ??? ?? detach ???? JQuery?? ??? ?????? JQuery ???? ?? ???? ???? ???? ??? ? ??? ????.

$("p? ?? ???? ?? ??? ?????. ").detach() P ??? ?? ??? ? ??? p ??? ??? ?? ???? ?????. ???? ???? ???? ???? ???? ??? ? ????

?? ??? ???????.

<html>

<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
    <style type="text/css">
    p {
        color: red;
    }
    </style>
</head>

<body>
    <p>P元素1,默認(rèn)給綁定一個點擊事件</p>
    <p>P元素2,默認(rèn)給綁定一個點擊事件</p>
    <button id="bt1">點擊刪除 p 元素</button>
    <button id="bt2">點擊移動 p 元素</button>
    <script type="text/javascript">
    $('p').click(function(e) {
        alert(e.target.innerHTML)
    })
    var p;
    $("#bt1").click(function() {
        if (!$("p").length) return; //去重
        //通過detach方法刪除元素
        //只是頁面不可見,但是這個節(jié)點還是保存在內(nèi)存中
        //數(shù)據(jù)與事件都不會丟失
        p = $("p").detach()
    });

    $("#bt2").click(function() {
        //把p元素在添加到頁面中
        //事件還是存在
        $("body").append(p);
    });
    </script>
</body>

</html>


???? ??
||
<html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script> <style type="text/css"> p { color: red; } </style> </head> <body> <p>P元素1,默認(rèn)給綁定一個點擊事件</p> <p>P元素2,默認(rèn)給綁定一個點擊事件</p> <button id="bt1">點擊刪除 p 元素</button> <button id="bt2">點擊移動 p 元素</button> <script type="text/javascript"> $('p').click(function(e) { alert(e.target.innerHTML) }) var p; $("#bt1").click(function() { if (!$("p").length) return; //去重 //通過detach方法刪除元素 //只是頁面不可見,但是這個節(jié)點還是保存在內(nèi)存中 //數(shù)據(jù)與事件都不會丟失 p = $("p").detach() }); $("#bt2").click(function() { //把p元素在添加到頁面中 //事件還是存在 $("body").append(p); }); </script> </body> </html>