jQuery check if an input is type checkbox?

Rio picture Rio · Sep 28, 2009 · Viewed 129.3k times · Source

I'd like to find out if an input is a checkbox or not, and the following doesn't work:

$("#myinput").attr('checked') === undefined

Thank you once again!

Answer

Ken Browning picture Ken Browning · Sep 28, 2009

You can use the pseudo-selector :checkbox with a call to jQuery's is function:

$('#myinput').is(':checkbox')