jquery--获取多选框的值、获取下拉多选框的值

时间:2023-03-09 08:39:06
jquery--获取多选框的值、获取下拉多选框的值

获取多选框的值

var packageCodeList=new Array();
$('#server_id:checked').each(function(){
packageCodeList.push($(this).val());//向数组中添加元素
});
console.log(packageCodeList)

获取下拉多选框 select   multiple

var packageCodeList=new Array();
$("#businessRootEnvSelect option:selected").each(function(){
packageCodeList.push($(this).val());//向数组中添加元素
});