test-619.html 667 B

12345678910111213141516171819202122232425262728
  1. <html>
  2. <head>
  3. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
  4. <link href="select2.css" rel="stylesheet"/>
  5. <script type="text/javascript" src="select2.js"></script>
  6. </head>
  7. <body>
  8. <select id="s1">
  9. <option value="A"></option>
  10. <option value="B"></option>
  11. </select>
  12. <script type="text/javascript">
  13. $(document).ready(function () {
  14. $("#s1").select2({}).on("change", function () {
  15. alert("Changed caused by val()");
  16. }).select2("val", "A");
  17. // This should not trigger a change
  18. $("#s1").select2("val", "B", false);
  19. });
  20. </script>
  21. </body>
  22. </html>