jQuery detach()

如下代码实现不了,什么鬼?

<!doctype html>
<html lang="en">
<head>
 <meta charset="utf-8"/>
 <title>jQuery</title>
</head>
<body>
 <p title="选择你最喜欢的水果.">你最喜欢的水果是?</p>
 <ul>
    <li title='苹果'>苹果</li>
    <li title='橘子'>橘子</li>
    <li title='菠萝'>菠萝</li>
 </ul>
 <script src="scripts/jquery.js"></script>
 <script type="text/javascript">

       $("ul li").click(function(){
  alert($(this).html());
        });
    var $li=$("ul li:eq(1)").detach();
    $li.appendTo("ul");

</script>

</body>
</html>  




猜你喜欢

转载自blog.csdn.net/weixin_42607424/article/details/81027617