I am trying to fire parent click event whenever an input change happens.
Below is my code, it is firing Click event for two times.
$('TABLE TBODY TR TD INPUT').change(function()
{
$(this).parents('TD').click();
});
$('TABLE TBODY TR TD').click(function()
{
alert("Clicked me...");
});
Here is my HTML Code
<table>
<tr><td>foo<input type="radio"></td><td>foo<input type="checkbox"></td></tr>
<tr><td>foo<input type="radio"></td><td>foo<input type="checkbox"></td></tr>
<tr><td>foo<input type="radio"></td><td>foo<input type="checkbox"></td></tr>
</table>
Where is the mistake…
so the
inputis also intdso both are being clicked.this only returns one alert, but I have a feeling you dont want to alert, but rather change the parent element.
but I bet you probably want the following
live example: http://jsfiddle.net/nFtzJ/
here every time the input changes, the parent
<td>has the class .clicked toggled, of course this can be changed, but its almost a faux pas to usealert();in production.