<ul class="swiper-wrapper">
<li class="swiper-slide">
<img src="./images/banner-1.jpg" alt="">
<span class="slider-text"></span>
</li>
<li class="swiper-slide">
<img src="./images/banner-2.jpg" alt="">
<span class="slider-text"></span>
</li>
<li class="swiper-slide">
<img src="./images/banner-3.jpg" alt="">
<span class="slider-text"></span>
</li>
<li class="swiper-slide">
<img src="./images/banner-4.jpg" alt="">
<span class="slider-text"></span>
</li>
</ul>
我想复制li
标签本身包括所有子元素到第一个li
标签前面,jquery有简单的写法。
var swiperPic = $(".swiper-slide")
var liHtml = swiperPic.eq(swiperPic.length - 1).html()
swiperPic.eq(0).before("<li class="swiper-slide">" + liHtml +"<li>")
我想到的是能复制li
标签下所有子元素但是不包括li
标签本身。