function SelectReceipt() { var checknum = 0; var customerCode = ""; var type = ""; var url = ""; checknum = $("input:checked").length; if ( checknum > 1) { alert("Only one record can be selected for payment!"); return false; } else { alert( checknum); if (checknum == 1) { customerCode = $("input:checked").next().attr("value"); //Get through the next() method , if you want to get the next hdCustomerName value, you can .next().next(). //customerName = $("input:checked~#hdCustomerName").val();//IE will report an error when using ID, but firefox will not type = $("input:checked~.hdStatus") .attr("value");//Or get it by using class, url = 'PreReceiptDeposit.aspx?customerCode=' customerCode '&departmentType=' type; } else { url = 'PreReceiptDeposit.aspx?customerCode=' '' '&departmentType=' type; } alert(url); UniversalOpenWindowAndBreak(640, 600, url, 1); return true; } }
jQuery.attr gets/sets the attribute value of the object, such as: $("input[name='chk_list']").attr("checked"); //Read all names whose name is 'chk_list' 'The status of the object (whether it is selected) $("input[name='chk_list']").attr("checked",true); //Set checked to true for all objects named 'chk_list' Another example: $("#img_1").attr("src","test.jpg"); //Set the value of src with ID of img_1 to 'test.jpg' $("#img_1").attr("src"); //Read the src value with ID img_1 The following code is to get the value of the checkbox selected in the above example:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn