var temp = document.querySelectorAll("input[name]");
var data = {};
for (var i = 0; i < temp.length; i++) {
data[temp[i].name] = temp[i].value;
}
delete data.sex
var item = null
var obj = document.getElementsByName("sex")
for (var i = 0; i < obj.length; i++) { //遍历Radio
if (obj[i].checked) {
item = obj[i].value;
}
}
console.log(data)
console.log(item)
JQuery 获取所有input值和单选框选中的值
最新推荐文章于 2022-02-19 16:07:56 发布