jQuery: How to display a div after selected an option

After selecting an option (or more) from a dropdown list (or other), you may want to display some description or more options. What i do here is to display a div consisting of some checkboxes.
Here’s how i do it:

$('#checkbox_1').hide();

$('select').change(function(){
if ($('#choice_1').is(':selected')){
$('#checkbox_1').show();
}
else{
$('#checkbox_1').hide();
}
});

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s