I am running the below code in my system but the dropdown box is not working. I ran in JSFiddle, its working fine but in my system, its not. I tried in Chrome, Firefox and Safari as well but no luck.
Can you please tell me what I am doing wrong. Thanks in advance.
My code:
<html>
<body>
<select name="cars" id="cars" multiple="multiple">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
<option value="santro">Santro</option>
</select>
<script>
$("#cars").multiselect({
buttonText: function(options, select) {
console.log(select[0].length);
if (options.length === 0) {
return 'Add To';
}
else {
var cars_selected = [];
console.log(options);
options.each(function() {
cars_selected.push($(this).val());
});
return cars_selected.join(', ') + '';
}
}
});
</script>
</body>
</html>
I am getting this in my browser:
jsfiddle: https://jsfiddle.net/ejqngpn5/893/
I was able to get this working locally on my Mac by adding jQuery
1.9.1 and bootstrap-multiselect.js
. Check to make sure these are being included in your local.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.