Skip to content

Instantly share code, notes, and snippets.

@nocodesupplyco
Last active December 16, 2022 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nocodesupplyco/e01d4268e170866f57bc93bd76ed807f to your computer and use it in GitHub Desktop.
Save nocodesupplyco/e01d4268e170866f57bc93bd76ed807f to your computer and use it in GitHub Desktop.
Hide/Show Element From <select>
$(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