user576510
user576510

Reputation: 5915

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

I have a checkbox column in gridview and getting its Click event. But I just has relised I do not need Click 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.

Upvotes: 0

Views: 3127

Answers (3)

Kyle
Kyle

Reputation: 4449

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

Upvotes: 1

Luke Duddridge
Luke Duddridge

Reputation: 4347

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

Upvotes: 1

Avi Pinto
Avi Pinto

Reputation: 4336

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

Upvotes: 1

Related Questions