Tuesday, 27 August 2013

Adding a closing tag to the DOM before an element

Adding a closing tag to the DOM before an element

I'm needing to insert a closing tag before an element in the DOM. But
jQuery doesn't like the idea of inserting what it believes to be malformed
markup.
To provide a little context, I'm needing to do it this way because I am
unable to alter the code displayed by the Wordpress the_content()
function. All I'm doing is closing a wrapper div, which I will open again
after the next element, so there won't actually be any malformed code.
I suppose I'm looking for something similar to the following:
$('</div><!-- Close Mobile Wrapper -->').insertBefore('.right-col');
But the above renders nothing in the source. Is there any way around this?

No comments:

Post a Comment