Created
September 20, 2016 09:00
-
-
Save jimmy89Li/095ed56f21b44c1fcb38ace3dbd1a6e5 to your computer and use it in GitHub Desktop.
Show divs based on selected options value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Select id="packageOption"> | |
<option value="">None</option> | |
<option value="package1">Package1</option> | |
<option value="package2">Package2</option> | |
<option value="package3">Package3</option> | |
</Select> | |
<div id="package1" class="packages" > Package1 </div> | |
<div id="package2" class="packages" > Package2 </div> | |
<div id="package3" class="packages" > Package3 </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('#packageOption').change(function(){ | |
$('.packages').hide(); | |
$('#' + $(this).val()).show(); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.packages { | |
display:none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment