I have a variable (div element) which contains some table html.
I can use this javascript to add a class to each cell that has a background set.
var tds = tempDiv.getElementsByTagName("TD");
for (var j = 0; j < tds.length; j++) {
var oTd = tds[j];
if (oTd.style.background.length > 0) {
oTd.className = 'faketh';
oTd.setAttribute('style', 'Clear');
} //if
}//for
what i'd like to do is do the same in jquery. Below is what i've come up with, and the second line works fine, but the first doesn't....
$(tempDiv).find("td[style*='background:']").addClass("faketh");
$(tempDiv).find("td").removeAttr('style');
Any help would be appreciated.
Edit: Just to add; I'm using the code below without issue.
$(tempDiv).find("tr:odd").addClass('row0');
$(tempDiv).find("tr:even").addClass("row1");
So its not the adding of the class thats the problem... The issue is that i'm not finding any matching elements. Here is one of the td elements;
<td valign="top" class="faketd" style="border: 1pt solid windowtext; padding: 0cm 5.4pt; background: silver none repeat scroll 0% 0%; width: 131.4pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
<p style="margin: 0cm 0cm 0pt; text-align: justify;"><strong>VPN Name/Description:</strong></p>
</td>