asp.net Repeater and Jquery
I have a repeater with a checkbox in the item template. During itemdatabound event of the repeater I add an attribute to the checkbox
((CheckBox)e.Item.FindControl("chkPresents")).Attributes.Add("accountName", ((DataRowView)e.Item.DataItem)["accountName"].ToString(开发者_StackOverflow社区));
I have a button that suppose to get all the checked checkbox and the account name associated with it.
How can I do this using jquery.
Thanks very much.
You can do following things.
$(docuement).ready(function()
{
$("#yourButtonID").live("click",function()
{
$('input[id*="chkPresents"]:checked').each(function() // mathing all checked imputs
{
$(this).attr("accountName") ; //is your accountName
$(this) //is reference to current checkbox
}
)
})
})
This would alert the "accountName" attribute for all checked checkboxes -
$(document).ready(function()
{
$("#clickbutton").click(function () {
$("input:checkbox[checked]").each(function () {
alert($(this).attr("accountName"));
}
)
});
});
http://jsfiddle.net/ipr101/bV96D/
精彩评论