將一個ul下的li轉移到另外一個ul裡面 【appendTo】,ulappendto

來源:互聯網
上載者:User

將一個ul下的li轉移到另外一個ul裡面 【appendTo】,ulappendto

<1>

<html xmlns="http://www.w3.org/1999/xhtml"><head>    <title>將一個ul下的li轉移到另外一個ul裡面</title>    <script src="script/jquery-1.11.0.min.js" type="text/javascript"></script>    <script type="text/javascript">        $(function () {            //建立一個節點            var li = $("<li>中國隊</li><li>美國隊</li><li>巴西隊</li><li>德國隊</li>")            //給這個節點添加到#ul1裡面            $("#ul1").append(li)            $("ul li").mouseover(function () {                $(this).css("background", "red").siblings().css("background", "White").click(function () {                    //$(this).appendTo($("#ul2"))的意思是將當前的li添加到#ul2裡面                    $(this).appendTo($("#ul2")).css("background","white")                })            })        })    </script></head><body><ul id="ul1" style=" float:left"></ul><ul id="ul2"style=" float:right"></ul></body></html>

             


Jquery 怎判斷當ul中的li超過一個指定數時,開始另一個ul

$('ul>li').length
返回就是ul下li的個數。

如果個數大於你指定的個數。 你就document.createElement('ul') 再建立一個ul唄。。。

是你想要的結果嗎?
 
jquery 如果擷取多個ul下面的第一個li

$(".a ul li:nth-child(1)")
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.