'why doesn't select2 multiselect work using cdn?
I'm using this code
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('#state').select2({
placeholder: "Select a state",
allowClear: true
});
});
</head>
And in body:
<div>
<select id="state" name="state" multiple>
<option value="AL">Alabama</option>
<option value="MY">Wyoming</option>
</select>
</div>
But still it doesn't look as needed What could be the problem?
Solution 1:[1]
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script>
</head>
<div>
<select id="state" name="state" multiple>
<option value="AL">Alabama</option>
<option value="MY">Wyoming</option>
</select>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('#state').select2({
placeholder: "Select a state",
allowClear: true
});
});
</script>
</div>
You are missing </script> tag
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Aayush Dahal |
