$(document).ready(function() {
$("#e1").select2();
});
<html>
<head>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.3.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css">
</head>
<body>
<select id="e1" style="width:300px" multiple="multiple">
<option value="AL">Alabama</option>
<option value="Am">Amalapuram</option>
<option value="An">Anakapalli</option>
<option value="Ak">Akkayapalem</option>
<option value="WY">Wyoming</option>
</select>
</body>
</html>
可能是您包含的JS
問題或與版本, 檢查我創建的小提琴。
https://jsfiddle.net/rev8vkcr/
檢查我的HTML代碼。
<html>
<head>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.3.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css">
<script type='text/javascript'>
$(document).ready(function() {
$("#e1").select2();
});
</script>
</head>
<body>
<select id="e1" style="width:300px" multiple="multiple">
<option value="AL">Alabama</option>
<option value="Am">Amalapuram</option>
<option value="An">Anakapalli</option>
<option value="Ak">Akkayapalem</option>
<option value="WY">Wyoming</option>
</select>
</body>
</html>
請檢查您是否在控制檯中發現錯誤。 –
我編輯了你的問題,沒有什麼看起來不對。 –
腳本標籤未關閉 –