Advertisement
MarkUa

Untitled

Jun 26th, 2019
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.19 KB | None | 0 0
  1. <html lang="en">
  2.  
  3.  
  4. <head>
  5.  
  6.  
  7.     <title>Jquery Select2 - Select Box with Search Option</title>
  8.  
  9.  
  10.     <script srcф="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
  11.     <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
  12.     <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
  13.  
  14.  
  15. </head>
  16.  
  17.  
  18. <body>
  19.  
  20.  
  21. <div style="width:520px;margin:0px auto;margin-top:30px;height:500px;">
  22.  
  23.  
  24.  
  25.  
  26.   <select class="myselect" style="width:500px;" onchange="changeSelect();">
  27.         <option value="" disabled selected>Search course by name</option>
  28.   </select>
  29.  
  30.  
  31. </div>
  32.  
  33.  
  34. <script type="text/javascript">
  35.      $(document).ready(function() {
  36.          var items = ["Laravel ACL", "Laravel Angural JS Crud",
  37.          "Laravel CRUD","Laravel PDF", "C++",
  38.          "gLaravel ACL", "yLaravel Angural JS Crud",
  39.          "tLaravel CRUD","yLaravel PDF", "tC++"]
  40.          for (var i of items)
  41.          $(".myselect").append(new Option(i, i));
  42.  
  43.      });
  44.       $(".myselect").select2();
  45.     $('.myselect').on('change', function() {
  46.   alert( this.value );
  47. });
  48. </script>
  49.  
  50.  
  51. </body>
  52.  
  53.  
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement