I understand the question beaten. But I did not find a clear answer. There is such a simple code:

$(document).ready(function () { $("#client_1").on("click", function () { alert('test'); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select> <option id='client_1'>Click me</option> </select> 

Everything works fine in firefox and IE, but it doesn't work in chrome. Jquery latest version is connected, there are no errors in the console, the files are all connected ... I don’t mind where to go.

  • one
    Everything works for me in chrome. - Beast Winterwolf
  • @ Alexander Cheremikin Both I and I, and I have such an opinion. - Vlad from Moscow
  • @Alexander Cheremikin I started such a script, and everything works $ (function () {$ ("# box"). On ("click", function () {alert ("Hi!");});}); - Vlad from Moscow
  • Check if you have something wrong with id or some buggy plugins are installed in chrome. - Beast Winterwolf
  • one
    Corrected. Snipe, I did not write. Now fixed. The FF works fine with chromium does not work. - Alexander Cheremikin

1 answer 1

Here is the solution. Thank you all for the direction. I am very glad that there are such responsive people here. Thank you for your patience and understanding!

 $("#agent_1").on('change', function() { if ($(this).find(':selected').val() === '1') { alert('test'); } else { alert('test2'); } }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select name="agents" id="agent_1"> <option value="1">Test</option> <option value="2">Test2</option> </select> 

  • one
    you can take the value not as you do (this is terrible), but immediately from the event that goes to the input in the handler ( on('change', function(event) ). event.target.value will be the value of the selected option - Vasily Barbashev
  • Thank you very much. For the future I will consider. - Alexander Cheremikin