The Project Center introduced the Select2 plugin. Advantages: Can be multiple selection, search, disadvantage: Access value is not as convenient as SELECT.
Select2 Value:
Take Textvar strtext = $ (' #select2 '). Select2 (' data '). Text;
Take value
var str2value= $ ("#Select2"). Select2 ("Val");
Multi-Select
$ (' #select2 '). Select2 ({ // allowclear: true,// data:[{id:0,text: ' Hello '}, {id:1,text: ' World '}] // }); </script>
<select id= "Select2" > </select>
SELECT2 upgrade, support multi-Select, with Select2 (' data ') is an array, not a JSON,
Because of the need for Select2 (' data ') [0].text can get the corresponding value, multiple words are recycled
Select2 Assignment Value:
page with razor <div class= "Form-group" > <label class= "Control-label" > sales Staff: </ Label> { @id = "Salesman", @class = "Select2", @style = "width:67%;} ) <span class= "Help-line" > @Html. validationmessagefor (M = m.salesman) </span> </ Div>js: <script type= "Text/javascript" >//Example: Assigning a select2 tag to a valueof @Html. Raw ("$ (' #SalesMan '). val ("All") $ ("#SalesMan"). Select2 (); }); </script>
Select2 Value Assignment