开发者

How to insert opening div in jQuery?

I want to insert an opening div but it closes itself automatically. How do I get this to work.

I want to wrap thses two divs in one div called controls...

<div class="carousel-prev prev-next"></div>
<div class="carousel-next prev-next"></div>

So I get...

<div id="controls">
<div class="carousel-prev"></div>
<div class="c开发者_StackOverflow社区arousel-next"></div>
</div>

I did try:

$(".jcarousel-prev").before("<div id='controls'>");

But as I mentioned above, it closes automatically.


$(".prev-next").wrapAll("<div id='controls'>");

in your particular case you're removing class too i.e.

$(".prev-next").removeClass('prev-next').wrapAll("<div id='controls'>");


You can use .wrapAll():

$(".prev-next).wrapAll('<div />');


You should use wrap function to achieve that:

http://api.jquery.com/wrap/


try this...

$(".prev-next").appendTo("<div id='controls'>");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜