I am trying to implement the following: change the CSS property visibility: of an<input> tag using a javascript function when the user selects an <option> from a <select>.
Here's my code so far:
main.js:
function change_css(){
if( $('#billing_method').val() == "CLICK THIS TO CHANGE VISIBILITY" ){
$('#the_input').css({ 'visibility': 'visible' });
}else{
$('#the_input').css({ 'visibility': 'hidden' });
}
}
page.html:
<select name="billing_method">
<option onClick='change_css()'>-- SELECT AN OPTION --></option>
<option onClick='change_css()'>CLICK THIS TO CHANGE VISIBILITY</option>
</select>
<input type="text" id="the_input" value="" placeholder="I AM THE INPUT" />
styles.css:
#the_input{
visibility: hidden;
}
See jsfiddle