Blynn
Blynn

Reputation: 1411

jQuery wrapping of a tr td with jQuery

I'm trying to wrap my table with a new tr and then all the td's inside the wrapping tr.

My code is as follows:

$('.ccbnBgTblTxt td').wrap('<tr class="new"/>');

What I'm trying to do is.. this

<tr class="new"><td></td><td></td><td></td></tr>

Right now I'm getting results like this.

<tr class="new"><td></td></tr><tr class="new"><td></td></tr>

Anyway to wrap all the td's?

Upvotes: 1

Views: 863

Answers (1)

tymeJV
tymeJV

Reputation: 104775

Try using the .wrapAll() function

$('.ccbnBgTblTxt td').wrapAll('<tr class="new"/>');

Upvotes: 3

Related Questions