我有以下代码: ASP.NET:
<body>
<form id="frm" runat="server">
<asp:Panel ID="pnl_seat" runat="server">
<asp:PlaceHolder ID="plhdr_seat" runat="server">
<table>
<tr>
<td>dynamic checkbox controls generated with ids such as check_0, check_1...</td>
</tr>
</table>
</asp:PlaceHolder>
<br />
<asp:Button ID="btn_submit" runat="server" Text="Submit" />
</asp:Panel>
<div id="results"></div>
</form>
JQUERY:
$(document).ready(function () {
$("btn_submit").click(function () {
x = $("frm").serializeArray();
$.each(x, function (i, field) {
$("#results").append(field.name + ":" + field.value + " ");
});
});
});
我希望div中的输出为check_0:checked或check_0:true。请帮我解决这个问题。
答案 0 :(得分:0)
试试这个:
$(document).ready(function () {
$("#btn_submit").click(function () { // add the # for id selector
x = $("#frm").serializeArray(); // here too.
$.each(x, function (i, field) {
$("#results").append(field.name + ":" + field.value + " ");
});
});
});