获取选中的名
var cardTypeW = $("#cardType option:checked").text();
获取选中的值
写法1
var cardTypeW = $("#cardType option:checked").val();
写法2
var cardTypeW = $("#cardType").find("option:selected").val();
方法三
//取text
var strtext = $('#select2').select2('data').text;
//取value
var str2value= $("#select2").select2("val");
//多选
//$('#select2').select2({
// allowClear: true,
// data:[{id:0,text:'hello'},{id:1,text:'world'}]
// });
</script>
<select id="select2" > </select>
Select2升级以后,支持多选了,用select2('data')取出来是是数组,不在是一个json了,
因需要select2('data')[0].text 既可以取得对应的值,多个的话循环获取