So I’ve browsed around a lot looking for an answer, but I couldn’t find anything that meets what I’m looking for.
So I’m editing a forum, that’s very locked in terms of adding new css classes to customize the look. So, I want to set it so, I can add a div class before the fixed class.
Example of the fixed class:
<div class="titlemedium"> </div>
What I’m trying to do using Jquery:
<div class="divthatcomesbefore"> <div class="titlemedium"> </div> </div>
Basically, I want the divthatcomesbefore to auto wrap around the titlemedium using JS, and I have no idea how to do it. Please help.
This is the script I tried to write, needless to say, it didn’t work.
<script> $(".divthatcomesbefore").before('<div class="titlemedium"></div>'); </script>
2
Answers
You might want to use jQuery’s .wrap() method
or in plain JavaScript:
Does this help?