I have a checkbox column in gridview and getting its Click event. But I just has relised I do not need Cli开发者_开发知识库ck event rather I need to know the events if checkbox is checked or unchecked on Client side. But these events are not available.
Please guide how to handle this.
use delegate on the column by setting a css class to the checkboxs. then listen to the click event of these checkboxes and check the .checked property of the actual dom element
you are probably looking to check that the checkbox input is(":checked")
Check out my example on jsfiddle: http://jsfiddle.net/RWCZK/
$("#checked").click(function()
{
if($(this).is(":checked"))
{
$("#show").hide();
}
else
{
$("#show").show();
}
});
You can still use your click event. Inside of the function use:
$('#mycheckbox').click(function()
{
if($(this).prop('checked'))
{
//Do something here
}
else
{
//Do something else here
}
});
精彩评论