注册 登录
编程论坛 jQuery论坛

请问怎么动态的获取li下面的所有信息,把他追加到另一个ul下的里里面去

qzx10010 发布于 2018-09-08 12:55, 3974 次点击
                            <div class="contains">
                        <ul>
                                <li>
                        <div class="work-cover">
                        <a href="#" title="宇宙战狼">
                            <img src="img/cover_1.jpg"/>
                        </a>   
                        </div>
                        <div class="information">
                            <h3>
                                <a href="#" title="宇宙战狼">宇宙战狼</a>
                                <i class="information-icon-sign">
                                    <span class="spaico">
                                        签约
                                    </span>
                                </i>
                                <i class="information-icon-info information-icon-sign">
                                    <span class="spaico">
                                        精品
                                    </span>
                                </i>
                            </h3>
                            <p title="悟漫田 图:翟浩羽 文:翟浩羽" class="information-workers">悟漫田 图:翟浩羽 文:翟浩羽
                            </p>
                            <p>
                                <a href="#">科幻</a>
                                <a href="#">冒险</a>
                                <span >
                                    "人气:"
                                    <em>3934.25万</em>
                                </span>
                            </p>
                            <p class="juqing">
                                一个失误造就了魇兽横行的废土未来;又一个失误成就了血性英雄的力挽狂澜。狂沙、兽海、以及挣扎扭曲的赤裸
                            </p>
                            <a href="#" class="reds">开始阅读</a>
                        </div>
5 回复
#2
icecool2018-12-11 08:35
程序代码:

<html>
<head>
<title>test</title>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){

                      $("button").click(function(){
                                  var htx=$(".ul1").html();
                                  $(".ul2").append(htx);
                       });
});

</script>
</head>
<body>
<ul class="ul1" id="ul1">
        <li>1.aaaaaaaaaaaaaaaa</li>
        <li>2.bbbbbbbbbbbbb</li>
        <li>3.cccccccccccccccc</li>
</ul>
<button>插入</button>
<ul class="ul2">
</ul>
</body>
</html>
#3
a135688748812019-02-11 11:35
回复 2楼 icecool
貌似这里用text()更好吧
#4
hmhz2019-02-11 17:25
就按2楼的没错的
$(".ul2").append($(".ul1").html());
#5
firstbobo2019-04-24 09:51
一次获取全部 li;我还想着一个一个取;
#6
讨厌鱼的猫2020-11-05 19:13


$("li").html();   //获取li下面的数据,

//图片url节点是唯一的,自定义一个id,反之就用顶一个class。
$("#").empty().html('获取到的数据');
1