General Question
How to mimic jQquery's appendTo with a regular expression?
Hi!
I use WordPress to manage a website and I’m currently (still… :) ) developing a theme. Now, I wrap some content in a div with a specific class to box it, but I want to append a clear:both
-div to that div in case there are any floating elements. I use jQuery as a temporary solution, like so:
$(’.block’).append(’<div class=“clearboth”></div>’);
I figure this can also be done with another way. Problem is, I have no clue how I’d go about something like this. Can I use any WordPress functions or would a regex be appropriate here?
I think it has to go something like this.
• Find all <div> start tags ”<div ”
• Find class=”
or class=’
• Look for the class name (e.g. ”block
”) before ”
or ’
.
• Then append the clear:both
-div just before the corresponding </div>
tag.
I hope someone can help.
Thanks!
Davey
1 Answer
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.