Add a surrounding div with jQuery?
Bit tricky to communicate but hope this makes sense.
I have 8 div containers and need to wrap all the even numbers with an extra div using Jquery, the desired effect like so,
<div id="wrapper">
<div id="content">
</div></div>
<div id="content">
</div>
<div id="wrapp开发者_如何学Pythoner">
<div id="content">
</div></div>
$('div.content:even').wrap('<div class="wrapper"></div>');
Note: I changed id to class since you can't have multiple elements with the same id.
Not sure but something like this maybe:
$('#continer:even').wrap('<div id="wrapper" />');
Also note that this will probably not work to good since the is only allowed one element with the same id. Change it to a class instead. And use '.' instead of '#' in the selector.
Why do you want to do this? Is it a style issue? The it probably can be solved using CSS.
..fredrik
Edit: seems that without the editor one can't post HTML code. Ken's way is the way to do it.
精彩评论