开发者

click event of checkbox in gridview, how to know it was checked or unchecked?

开发者 https://www.devze.com 2023-03-26 11:04 出处:网络
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

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
   }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消