disabled-mode.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <section>
  2. <h1 id="disabled">Disabled mode</h1>
  3. <p>
  4. Select2 will respond to the <code>disabled</code> attribute on
  5. <code>&lt;select&gt;</code> elements. You can also initialize Select2
  6. with <code>disabled: true</code> to get the same effect.
  7. </p>
  8. <div class="s2-example">
  9. <p>
  10. <select class="js-example-disabled js-states form-control" disabled="disabled"></select>
  11. </p>
  12. <p>
  13. <select class="js-example-disabled-multi js-states form-control" multiple="multiple" disabled="disabled"></select>
  14. </p>
  15. <div class="btn-group btn-group-sm" role="group" aria-label="Programmatic enabling and disabling">
  16. <button type="button" class="js-programmatic-enable btn btn-default">
  17. Enable
  18. </button>
  19. <button type="button" class="js-programmatic-disable btn btn-default">
  20. Disable
  21. </button>
  22. </div>
  23. </div>
  24. <pre data-fill-from=".js-code-disabled"></pre>
  25. <script type="text/javascript" class="js-code-disabled">
  26. $(".js-programmatic-enable").on("click", function () {
  27. $(".js-example-disabled").prop("disabled", false);
  28. $(".js-example-disabled-multi").prop("disabled", false);
  29. });
  30. $(".js-programmatic-disable").on("click", function () {
  31. $(".js-example-disabled").prop("disabled", true);
  32. $(".js-example-disabled-multi").prop("disabled", true);
  33. });
  34. </script>
  35. </section>