jquery获取radio,select,checkbox的值-精简版
// 循环获取radio的值
Js代码- var level_important = 0;
- var list = $("input[type='radio'][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[type='radio'][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[type='checkbox'][name='ids']");
- 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[type='checkbox'][name='ids']");
- 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();
复制代码 |