Wednesday, 4 September 2013

Jquery naming radio buttons to hide/show

Jquery naming radio buttons to hide/show

I have several sets of radio buttons on a form - they all need to be
independent (in pairs). When a set called "time" are selected I need 'Yes'
to show <p> and no to leave it hidden. I have set <p> as hidden using CSS
and the below code works on 1 set of radio buttons however when I start
adding the others in I don't want selecting 'Yes' on this first set to
show all <p> across the from (to differentiate <p> I will be calling them
<p1>, <p2> etc...
How do I name the radio buttons in the below script to only affect the
with the 'time' radio buttons are selected.
<script>
$(document).ready(function(){
$(":radio:eq(0)").click(function(){
$("p").show();
});
$(":radio:eq(1)").click(function(){
$("p").hide();
});
});
</script>
Thanks in advance.
Tom

No comments:

Post a Comment