Skip to content

Instantly share code, notes, and snippets.

@glennyboy
Last active October 30, 2019 20:30
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 glennyboy/a61e34ff2b02df617e8e0321370837c1 to your computer and use it in GitHub Desktop.
Save glennyboy/a61e34ff2b02df617e8e0321370837c1 to your computer and use it in GitHub Desktop.
jQuery Add Other input box to select dropdown
<script>
// Use jquery .change() to bind change event of an element
// Give your form ID of #form
// Add your select with option of 'Other' and add input with class of .inputvis with initial CSS display of none
jQuery( document ).ready(function($) {
var Select = '#form select';
$(Select).change(function(){
if($('Select option:selected').text() == "Other"){
$('.inputvis').show();
}
else{
$('.inputvis').hide();
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment