I have an unordered list (ul) that i’m trying to insert some tags before and after the (ul). It seems to insert my tags just fine before the (ul), but for some reason, it won’t insert it after. Here’s the jsfiddle: http://jsfiddle.net/grem28/ptSVA/1/
$('.isNav').addClass('nav').before('<nav class="navbar navbar-inverse"><div class="navbar-inner">').after('</div></nav>');
If you inspect the results you’ll see what i’m talking about. Originally i had it chained, but it seemed to insert the before and after together and that is why i seperated it. I thought if i did the .after first then the .before it would show up correctly but it doesn’t work. All your help is greatly appreciated!
Thanks all
You have to use
wrap().before()andafter()do not add the actual HTML you pass to the function, they add the whole elements with closing tags. So the elements you added withbefore()were automatically closed and there are no “open” tags afterwards to be closed with yourafter()function.Example using
wrap:http://jsfiddle.net/ptSVA/2/