views:

74

answers:

3

How can I check if "this" is a checkbox?

This is the way to see if it is an selectbox

if($(this).parent().is('select'))   {

Now can I see wether it is a checkbox? So I tried this:

 }else if($(this).is(:Checkbox)){\n

But it gives me a syntax error. Any help is welcome.

+3  A: 

Have you tried:

if($(this).is(':checkbox'))
Rashack
A: 

How can I see if it's also checked?

sanders
$(this).is(':checked');
kkyy
+1  A: 

Checkbox:

if ($(this).is(":checkbox")) ...

Checked:

if ($(this).is(":checkbox:checked")) ...

Consult jQuery selectors.

cletus