jQuery check if an input is type checkbox? jQuery check if an input is type checkbox? javascript javascript

jQuery check if an input is type checkbox?


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

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


>>> a=$("#communitymode")[0]<input id="communitymode" type="checkbox" name="communitymode">>>> a.type"checkbox"

Or, more of the style of jQuery:

$("#myinput").attr('type') == 'checkbox'


$("#myinput").attr('type') == 'checkbox'