jQuery check if an input is type checkbox? Ask Question

jQuery check if an input is type checkbox? Ask Question

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!

ベストアンサー1

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

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

おすすめ記事