I have the following HTML code:
<tr id="1774" class="XXX"><td> <span class="YYY">
Element 1</span></td></tr>
<tr id="1778" class="XYZ"><td> <span class="ZZZ">Element 2
</span></td>
</tr>
I want to replace all the class attributes (just for <tr> s) but not for <td> s. (that would be XXX and XYZ). The replacement would be: *XXX_suffix, XYZ_sufix*
Here is my workaround, but it replaces all the class attributes (in elements too!).
var htmlBlock= "<tr id="1774" class="XXX"><td> <span class="YYY">...</span></td></tr>";
htmlBlock+="<tr id="1778" class="XYZ"><td> <span class="ZZZ">...</span></td></tr>";
htmlBlock= htmlBlock.replace(/class="\s*(\w*)/g, "class=\" $1 " + _suffix);
But how can I replace just the tr class attribute ??
Is there another way in jQuery ??