如何在关闭之前在<ul>标签后添加容器<div>并关闭容器</ul> </div>

时间:2015-09-29 12:08:56

标签: jquery

<div class="container">
    <ul class="flex-direction-nav" id="yui_3_17_2_2_1443528053909_462"></ul>
</div>

如何使用jquery为ul flex-direction-nav添加容器div 像

images[]

2 个答案:

答案 0 :(得分:1)

&#13;
&#13;
$('.flexslider .flex-direction-nav').wrap($('<div class="container">'));
&#13;
.container ul {
  color: red;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="flexslider" id="yui_3_17_2_2_1443528053909_458">
  <ul class="slides" id="yui_3_17_2_2_1443528053909_457">
    <li style="width: 100%; float: left; margin-right: -100%; display: list-item;" id="yui_3_17_2_2_1443528053909_456">hello</li>
    <li style="width: 100%; float: left; margin-right: -100%; display: none;" id="yui_3_17_2_2_1443528053909_476">hello</li>
    <li style="width: 100%; float: left; margin-right: -100%; display: none;">hello</li>
    <li style="width: 100%; float: left; margin-right: -100%; display: none;">hello</li>
  </ul><br>
  <ul class="flex-direction-nav" id="yui_3_17_2_2_1443528053909_462">
    <li><a class="prev" href="#">Previous</a>
    </li>
    <li id="yui_3_17_2_2_1443528053909_461"><a class="next" href="#" id="yui_3_17_2_2_1443528053909_460">Next</a>
    </li>
  </ul>
</div>
&#13;
&#13;
&#13;

使用wrap()

$('.flexslider .flex-direction-nav').wrap($('<div class="container">'));

答案 1 :(得分:0)

使用jQuery wrapInner()方法 代码是这样的 $('。flexslider ul')。wrapInner('');