Here is my HTML code
<span class="xxt" style="">Hide Me</span>
<div><br/></div>
<div></div>
<span style="">
<table>
<tr>
<td style="">
<div></div>
<input type="radio" class="a">
</td>
</tr>
</table>
</span>
<span class="xxt" style="">Hide Me</span>
<div><br/></div>
<div></div>
<span style="">
<table>
<tr>
<td style="">
<div></div>
<input type="radio" class="a">
</td>
</tr>
</table>
</span>
I am trying to access the closest span element with class "xxt" which is nearer to the parent span of the changed radio button.
Here is my code
$('.a').live('change',function()
{
$(this).parents('span').closest('.xxt').addClass('DestQID');
$('.DestQID').hide();
});
Here is my test jsfiddle
Try this:
$('.a').live('change',function()
{
$(this).closest('span').prevAll('.xxt:first').addClass('DestQID');
$('.DestQID').hide();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With