TriSTaR TriSTaR - 1 year ago 112
Javascript Question

jQuery addClass over html Tags

I want to

over tags with jQuery...

For example: I have this

<h4>Any title</h4>
<p> Text intro </p>

I wanna add the Class over it's..

<div class="myClass">
<h4>Any title</h4>
<p> Text intro </p>

UPD Thank you all )

Answer Source

$('h4,p').wrapAll("<div class=myClass></div>")
.myClass {
  color: red
<script src=""></script>
<h4>Any title</h4>
<p>Text intro</p>

Use .wrapAll()

Description: Wrap an HTML structure around all elements in the set of matched elements.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download