I would like to create opening and closing html tags around an existing html structure with JavaScript or jQuery.
The html structure looks like this:
<div class="coursePrerequisites">
<p>
Lorem ipsum..
</p>
</div>
I would like to wrap the p tag inside a div with the class .description-wrapper dynamically.
How can I do that with JavaScript or jQuery?
您可以使用jQuery wrap()函数来做到这一点。
$( ".coursePrerequisites p" ).wrap("<div class='description-wrapper'></div>");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.