I have a dynamically loaded table where each row has a checkbox option, with an assigned #id of either 1,2 or 3. I need to make a function that will shows a hidden div corresponding to the #id of the checkbox checked. I'm currently using .change() to trigger the function, but this ends up showing the hidden div when unchecking a box, which I do not want to happen. Is there another way to trigger this function for just on "checked", and not "unchecked". See code below:
<tr>
<td >
<input id="1" class="link_contact" type="checkbox"/>
</td>
</tr>
<tr>
<td >
<input id="2" class="link_contact" type="checkbox"/>
</td>
</tr>
<tr>
<td >
<input id="3" class="link_contact" type="checkbox"/>
</td>
</tr>
<div class="1" style="display:none;"> Some Hidden Text</div>
<div class="2" style="display:none;"> Some Hidden Text</div>
<div class="3" style="display:none;"> Some Hidden Text</div>
<script>
$(document).ready(function () {
$(".link_contact").change(function () {
$("." + $(this).attr('id')).fadeIn(800);
$("." + $(this).attr('id')).delay(7000).fadeOut(800);
});
});
</script>
Thanks, Mark