125
rated 0 times
[
132]
[
7]
/ answers: 1 / hits: 26896
/ 11 Years ago, fri, november 15, 2013, 12:00:00
I really don't know much about javascript, but I am trying to use the following code which works well. The problem I am having is if I add a ... or : at the end of the Choose option, the code no longer works.
HTML:
<select id=dropDown>
<option>Choose</option>
<option value=div1>Show Div 1</option>
<option value=div2>Show Div 2</option>
</select>
<div id=div1 class=drop-down-show-hide>div 1</div>
<div id=div2 class=drop-down-show-hide>div 2</div>
Script:
$('.drop-down-show-hide').hide();
$('#dropDown').change(function(){
$(this).find(option).each(function()
{
$('#' + this.value).hide();
});
$('#' + this.value).show();
});
Any help is much appreciated! Thanks!
More From » jquery