I have a form with an interior portion which is laid out basically like this (due to the way it get's styled in the main directory it has to be laid out -poorly- like this):
<div id="q38_q42">
<ul name="q38" id="q38">
<li>
<input name="q38" type="radio" value="Yes">
</li>
<li>
<input name="q38" type="radio" value="No">
</li>
</ul>
<ul name="q39" id="q39">
<li>
<input name="q39" type="radio" value="Yes">
</li>
<li>
<input name="q39" type="radio" value="No">
</li>
</ul>
...[etc]
</div>
I'd like to have jQuery detect whenever a user clicks "No" for any input inside the <div id="q38_q42"> and display another div in a different location. The display function works fine, but I can't seem to get it to detect the input on click. This is what I've got so far just testing the first "No" input at name="q38" which still doesn't work:
function showDiv(div){$(div).slideDown();}
function hideDiv(div){$(div).slideUp();}
$('input[name=q38]').click(function(){
if ($('input[value=No]').prop('checked')){
showDiv('#q43_hidden');
} else {
hideDiv('#q43_hidden');
}
});
Thoughts?
Aucun commentaire:
Enregistrer un commentaire