[SELECT2] tags (ok)

C:\xampp\htdocs\php\lang.php

1. Sử dụng tags = true ngược lai nếu không sử dụng tags=true bạn sẽ không thêm được thẻ a.

C:\xampp\htdocs\php\lang.php

<!DOCTYPE html>
<head>
  <title></title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" />
  <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
  <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
  <style type="text/css">
  .flag {
    width: 15px;
    height: 15px;
    margin-right: 5px;
  }
  </style>
</head>
<body>
    <select id="tags" multiple="multiple" style="width: 400px;">
      <option value="Kerry" selected="selected">Kerry</option>
      <option value="Cork">Cork</option>
  </select>
  <script type="text/javascript">
    jQuery(document).ready(function($) {
      $('#tags').select2({
          tags: true,
          data: ["Clare","Cork","South Dublin"],
          tokenSeparators: [','], 
          placeholder: "Add your tags here",
          selectOnClose: true, 
          closeOnSelect: false
      });
    });
  </script>
</body>
</html>

Last updated

Navigation

Lionel

@Copyright 2023