show/hide DIV based on checkbox click

I have a checkbox in my form. If the checkbox is checked, I need to show a div tag. If it is unchecked, I need to hide the div tag.

Please help.

LVL 2
sshivannaAsked:
Who is Participating?
 
InsoftserviceCommented:
Hi,
I hope u have only one chk box.

<input type="checkbox" name="foo" value="bar" />

var value =  $('input[name=foo]').is(':checked') // to check whether its true or false 1st method
var value = $('input[name=foo]').attr('checked') // to check whether its true or false 2nd method
if(value ==true){
$('#divid').show();
}
else{
$('#divid').show();
}
0
 
sshivannaAuthor Commented:
sorry, I need to accomplish this using Jqeury.
Thank you
0
 
sshivannaAuthor Commented:
Thank you, the idea worked. I didn't realize that I can use a combo of javascript and jquery.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.