Last active
October 30, 2019 20:30
-
-
Save glennyboy/a61e34ff2b02df617e8e0321370837c1 to your computer and use it in GitHub Desktop.
jQuery Add Other input box to select dropdown
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
<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