I have a recurring table rows.
<table id="ads-content"><tr class="<?php
if ($i & 1) {
echo'alternate';
} else {
echo '';
}
?>">
<td align="left"><?php echo $i; ?></td>
<td align="left">
//some code to retrieve and print db values. at here $pcount is initialized. I can't initialize $pcount before tr.
</td>
<td><?php
if ($pcount != 1) {
echo "<img src='" . plugin_url('images/pencil2.png') . "'>";
} else {
echo "<img src='" . plugin_url('images/tick.jpg') . "'>";
}
?> </td>
</tr></table>
Problem:
I need to change the bg color of <tr>
in which contains the image "tick.jpg".
I tried so many ways but nothing fills the whole row.
How can I do this?
Answer
I fixed it. I will share the code I used to fix below so that it will help some other persons:
<table id="ads-content"><tr class="<?php
if ($i & 1) {
echo'alternate';
} else {
echo '';
}
?>">
<td align="left"><?php echo $i; ?></td>
<td align="left">
//some code to retrieve and print db values. at here $pcount is initialized.i can't initialize $pcount before tr.
</td>
<td><?php
if ($pcount != 1) {
echo "<img src='" . plugin_url('images/pencil2.png') . "'>";
} else {
<div class="to_class" style="display=none;"><?php echo "new"; ?></div>
echo "<img src='" . plugin_url('images/tick.jpg') . "'>";
}
?> </td>
</tr></table>
<script type="text/javascript">
$(function(){
$('#ads-content tr').each(function() {
var obtained= $(this).find("td").eq(2).find(".to_class").text();
$(this).addClass(obtained);
});
});
</script>
Note: eq() starts from zero, then I gave background colour for class "new" in the css part.