input操作

首页 > 前端开发 > javascript 更新日期:2022-11-16 09:51:16

默认选中第一个

适用于radio和checkbox。

$(".column").eq(0).prop('checked', true);

单选

$("input[name='column']:checked").val();

多选

html

<input class="bound_section" type="checkbox" title="" value="" />

js

var arr = [];
var ipt = $(".bound_section");
ipt.each(function(i){
     if(ipt.eq(i).prop('checked') == true){
           arr.push(ipt.eq(i).val());
     }
});
console.log(ipt)


标题导航