Guys help please, I can not write a javi script, I need that when I select the "input" block in the select "sale", well, so that it disappears when others choose
Select Sale Exchange Giftin the css block div id = "price" display: none;
Guys help please, I can not write a javi script, I need that when I select the "input" block in the select "sale", well, so that it disappears when others choose
Select Sale Exchange Giftin the css block div id = "price" display: none;
Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .
On the first select, an onchange event listener is hung onchange , which is called upon selection. Inside the function we check what is now selected: if the item we need is shown the second input.
Using jQuery, it looks like this:
a working example on jsfiddle (local snippets are spoiled): https://jsfiddle.net/ipshenicyn/0m8xbsy1/2/
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <select name="select" id="select"> <option value="1">Первый пункт</option> <option value="2">Второй пункт</option> <option value="3">Третий пункт</option> <option value="4">Четвертый пункт</option> </select> <input id="input" type="text" name="input" style="display:none"> Js
$("#select").on('change', function(){ if($(this).val() == 3){ $("#input").show(); } else { $("#input").hide(); } }) Source: https://ru.stackoverflow.com/questions/557585/
All Articles
onchangeevent listener is hungonchange, which is called upon selection. Inside the function, we check the current value (value) of our select: if the item we need is selected, we show the second input. And yes, @SleepyPanda is right, in such matters it is supposed to attach the existing code. html + js. preferably in the form of a snippet, which can be immediately launched. - Ivan Pshenitsyn