BootStrap selectpicker: How to dynamically bind data to the background, and selectpicker dynamically obtains
This article shares with you how to dynamically bind data to the BootStrap selectpicker background for your reference. The details are as follows:
Html code
<Select class = "selectpicker" multiple> </select>
This is a drop-down box, and now you need to dynamically add drop-down options to it.
Js Code
<Script type = "text/javascript"> getOption (); function getOption () {$. ajax ({type: "get", url: "test. json ", async: true, success: function (data) {var str =" "; for (var I = 0; I <data. length; I ++) {str + = '<option>' + data [I]. value + '</option>'} $ (". selectpicker "example .html (str); $ (". selectpicker "). selectpicker ('refresh') ;}}) ;}</script>
The key lies in $ (". selectpicker"). selectpicker ('refresh ');
If this sentence does not exist, the data cannot be bound.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.