I have this jsfiddle code. All I'm trying to do is hide / show a specific input object if select is checked.
JSFIDDLE CODE
The HTML part of the code is here:
<label for="add_fields_placeholder">Placeholder: </label> <select name="add_fields_placeholder" id="add_fields_placeholder"> <option value="50">50</option> <option value="100">100</option> <option value="Other">Other</option> </select> <div id="add_fields_placeholderValue"> Price: <input type="text" name="add_fields_placeholderValue" id="add_fields_placeholderValue"> </div>β
And the jQuery part is here:
$(document).ready(function() { $("#add_fields_placeholder").change(function() { if($(this).val() == "Other") { $("#add_fields_placeholderValue").show(); } else { $("#add_fields_placeholderValue").hide(); } }); });
Therefore, if the user selects "Other", he displays a different input object.
Now the problem is this. First, when you open the page, the first option is selected by default and an additional input object is displayed. It hides after choosing another option.
Is there any trick to hide it the first time the page loads? Not only when choosing a value manually.
Thanks guys.
jquery input hide show
inrob
source share