Search
 
SCRIPT & CODE EXAMPLE
 

HTML

select2

<!-- Style -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
<!-- Script -->
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
<script>
// In your Javascript (external.js resource or <script> tag)
$(document).ready(function() {
    $('.js-example-basic-single').select2();
});
</script>
Comment

select2 html example

<html>
        <script src="https://code.jquery.com/jquery-2.2.4.js"></script>
        <link href="https://rawgit.com/select2/select2/master/dist/css/select2.min.css" rel="stylesheet" />
        <script src="https://rawgit.com/select2/select2/master/dist/js/select2.js"></script>

        <select id="example" style="width: 300px">
            <option></option>
            <option value="JAN">January</option>
            <option value="FEB">February</option>
            <option value="MAR">March</option>
            <option value="APR">April</option>
            <option value="MAY">May</option>
            <option value="JUN">June</option>
            <option value="JUL">July</option>
            <option value="AUG">August</option>
            <option value="SEP">September</option>
            <option value="OCT">October</option>
            <option value="NOV">November</option>
            <option value="DEC">December</option>
        </select>

        <script>
            window.onpageshow = function() {
                $('#example').select2({
                    allowClear: true,
                    placeholder: 'Select a month'
                });
            };
        </script>
</html>

Comment

show html in select2 option

var data = [{
   id: 0,
   text: 'enhancement',
   html: '<div style="color:green">enhancement</div>'
}, {
   id: 1,
   text: 'bug',
   html: '<div style="color:red">bug</div><div><small>This is some small text on a new line</small></div>'
}];

function template(data) {
    return data.html;
}

$("select").select2({
   data: data,
   templateResult: template,
   escapeMarkup: function(m) {
      return m;
   }
});
Comment

select2

$(".js-example-basic-multiple-limit").select2({
  maximumSelectionLength: 3
});
Comment

select2

// In your Javascript (external .js resource or <script> tag)
$(document).ready(function() {
    $('.js-example-basic-single').select2();
});
Comment

PREVIOUS NEXT
Code Example
Html :: change the entire page font 
Html :: html figure 
Html :: when does useeffect return run 
Html :: tailwind nth child odd even 
Html :: bootstrap gutter 
Html :: tailwind custom column width 
Html :: oauth vs auth0 
Html :: angular open pdf in new tab 
Html :: html src online 
Html :: birthday wishes using html code 
Html :: html faq 
Html :: basic html template 
Html :: html collapsible open by default 
Html :: ul attributes in html 
Html :: using svg icons in html 
Html :: change html div jquery 
Html :: tabs characters in html 
Html :: on page load animation 
Html :: delete html 
Html :: how to jump line in html 
Html :: html marquee tag 
Html :: opening tag closing tag 
Html :: multiple countdown timer js 
Html :: link tag 
Html :: svg not rendering in chrome anymore 
Html :: date range picker select date and several weeks 
Html :: html tag for line break 
Html :: was not loaded because its mime type, “text/html”, is not “text/css”. react 
Html :: html button click go to section 
Html :: python timestanp 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =