jquery-select2 (not working)

Place for comments, problems, questions, or any issue related to the JavaScript / PHP scripts from this site.
User avatar
JanMolendijk
Posts: 142
Location: Holland Rotterdam

jquery-select2 (not working)

Dear admin I`m testing this script on my server
https://coursesweb.net/jquery/selec2_jp , but it does not work.

I simply did copy your code for a test on my XAMPP Version: 5.6.31

Code: Select all

<link href="css/select2.min.css" rel="stylesheet" />
<script src="js/select2.min.js"></script>

<script type="text/javascript" src="js/jquery.js"></script>

<select style="width:280px;" class="multi_sel" multiple="multiple" name="sel2">
<option value="v1">Alabama</option>
<option value="v2">Alaska</option>
<option value="v3">California</option>
<option value="v4">Nevada</option>
<option value="v5">New Mexico</option>
<option value="v6">Oklahoma</option>
<option value="v7">Oregon</option>
<option value="v8">Washingon</option>
</select>
<script>
$('.multi_sel').select2({
  placeholder: 'Select a state',
  maximumSelectionLength: 3
});
</script>
I hope you have some idea`s for me what i could do wrong ?

Admin
Hello,
When you use jquery plugins, you have to add the jquery library before the JS script with the plugin.
So, "js/jquery.js" before "select2.min.js".

Code: Select all

<script type="text/javascript" src="js/jquery.js"></script>
<script src="js/select2.min.js"></script>

JanMolendijk
Thank you for the support Admin,
i thought their was a problem with
the PHP-version or something else

It is working fine now (stupido me)

Similar Topics