你的位置:首页 > Java教程

[Java教程]select2使用详解


官网: https://select2.github.io/examples.html

 

引用:
<link href="~/Scripts/select2/select2.css" rel="stylesheet" />
<script src="~/Scripts/select2/select2.min.js"></script>
 
<input type="hidden" name="Data.ICD_10" id="Data.ICD_10" value="@Model.Data.ICD_10" />
 
<script type="text/javascript">  $(document).ready(function () {    var data = [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];     $("input[name='Data.ICD_0']").select2({      placeholder: "-请选择-", //请选择      allowClear: true,  //清楚选择项      data:data,       //绑定数据      minimumResultsForSearch: "-1"    });    if ($("input[name='Data.ICD_0']").val() != "") {      $("input[name='Data.ICD_0']").select2("val", $("input[name='Data.ICD_0']").val());  //赋默认值    }  });</script>