jquery获取radio,select,checkbox的值-精简版
jquery获取radio,select,checkbox的值-精简版// 循环获取radio的值
Js代码var level_important = 0;
var list = $("input[name='" + ("radio_level_important_" + id)
+ "']");
list.each(function() {
if ($(this).attr('checked') == "checked") {
level_important = $(this).val();
}
});
level_important = level_important == 0 ? 2 : level_important;
var level_important = 0;
var list = $("input[name='" + ("radio_level_important_" + id)
+ "']");
list.each(function() {
if ($(this).attr('checked') == "checked") {
level_important = $(this).val();
}
});
level_important = level_important == 0 ? 2 : level_important;循环获取checkbox的值
Js代码// 删除按钮单击事件
$("#delete").click(function() {
var ids = "";
var list = $("input");
list.each(function() {
if ($(this).attr('checked') == "checked") {
ids += $(this).val() + ",";
}
});
if ($.trim(ids)) {
ids = ids.substring(0, ids.length - 1);
if (confirm("确定要删除所选择的项次吗?")) {
location.href = "department!deleteBatch.action?department.code="
+ ids;
}
} else {
alert("请选择所要操作的项次!");
}
});
// 删除按钮单击事件
$("#delete").click(function() {
var ids = "";
var list = $("input");
list.each(function() {
if ($(this).attr('checked') == "checked") {
ids += $(this).val() + ",";
}
});
if ($.trim(ids)) {
ids = ids.substring(0, ids.length - 1);
if (confirm("确定要删除所选择的项次吗?")) {
location.href = "department!deleteBatch.action?department.code="
+ ids;
}
} else {
alert("请选择所要操作的项次!");
}
});判断checkbox是否选中
Js代码var report_status = $("#chk_report_status_" + id).attr('checked')
? "Y"
: "N";
var report_status = $("#chk_report_status_" + id).attr('checked')
? "Y"
: "N";获取select的值
Js代码var categories_belong = $("#categories_belong_" + id).val();
or
var categories_belong = $("#categories_belong_" + id).text(); 谢谢分享
页:
[1]