Hi all,
Thanks for your help with my previous problem (input blanking on click,
defaulting on blur if blank), worked a treat.
Now for a new one! Consider the following source:
<table id="vetotable">
<tr>
<td class="lalign">Name</td>
<td><input type="checkbox" name="x" value="y" /></td>
</tr>
</table>
And the following JS:
$("#vetotable td").not(".lalign").hover(function() {
$(this).addClass("hovertd");
},function() {
$(this).removeClass("hovertd");
}).click(function() {
$("input",this).attr("checked",!$("input",this).attr("checked"));
});
The purpose of the above is to highlight the cell when the mouse passes
into it, remove the highlight as the mouse leaves, and if the CELL is
clicked, toggle the checkbox inside it.
This works fine, HOWEVER if I click the checkbox directly, it first
checks, then unchecks itself giving no visible change to the end user.
I'm assuming this is because a click on the checkbox causes the check,
but then a click inside the table cell is detected, forcing the same
action and thus unchecking again.
How do I prevent this from happening so I can click the cell OR the
checkbox and achieve the desired result? Thanks :)
Regards,
Michael Price