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 ...

  • $("select").val(s); - Igor
  • Not! Doesn't work! ... - Alexander
  • The little gnome got out of the computer and said: “Doesn't work”? Works! - Igor
  • About the gnome you bent cool! But it doesn’t work ..... 4 hours no more damn work ... - Alexander
  • See sample code in response. - Igor

1 answer 1

 $(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