You must select the desired item in the <select> field.
There is a variable var s = $("#Cat").html(); .
It is known that it is equal to "Кофейня" .
It is precisely known that in the <select> field there is such an option.
How to select the desired item in the <select> field using the variable s ?
All that I found on the Internet could not screw ...
|
1 answer
$(document).ready(function(){ $("#btn").click(function(){ var s = $("#inputText").val(); $("#selectElement").val(s); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> Input:<input id="inputText" /> <br/> Select: <select id="selectElement"> <option>-</option> <option>one</option> <option>two</option> <option>three</option> </select> <br/> <button type="button" id="btn">From Input To Select</button> - Thank! Understood! The error was in the other! Very grateful! - Alexander
|
$("select").val(s);- Igor