[jQuery] Request for comments on code snippet.
i've just started using jQuery, and I'm having lots of fun.
I have the following code snippet. What it does is looks for all
instances of a <td>true</td> and <td>false</td> and replaces the
content with an image of a tick and cross.
The snippet is
$("td").each(function(){
if (this.innerHTML == 'true') {
this.innerHTML = '<img src="$base/images/true.png">';
}
if (this.innerHTML == 'false') {
this.innerHTML = '<img src="$base/images/false.png">';
}
});
I would just like to throw it out there, is there a neater way of
using jQuery to perform the same function ? I tried
$("td:contains('true')")
, but the <td> can be nested, which causes the parent <td> to be
replaced.