Last active
December 16, 2022 19:18
-
-
Save nocodesupplyco/e01d4268e170866f57bc93bd76ed807f to your computer and use it in GitHub Desktop.
Hide/Show Element From <select>
This file contains 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() { | |
$('.box').hide(); //hide | |
$('.red').show(); //set default class to be shown here, or remove to hide all | |
}); | |
$('select').change(function() { //on change do stuff | |
$('.box').hide(); //hide all with .box class | |
$('.' + $(this).val()).show(); //show selected option's respective element | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment