jQuery检查input是否为typescheckbox?
我想知道一个input是否是一个checkbox,下面是不行的:
$("#myinput").attr('checked') === undefined 再一次感谢你!
 您可以使用伪select器:checkbox调用jQuery的:checkbox is函数: 
 $('#myinput').is(':checkbox') 
 >>> a=$("#communitymode")[0] <input id="communitymode" type="checkbox" name="communitymode"> >>> a.type "checkbox" 
或者,更多的jQuery风格:
 $("#myinput").attr('type') == 'checkbox' 
 $("#myinput").attr('type') == 'checkbox' 
非jQuery解决scheme非常像jQuery解决scheme:
 document.querySelector('#myinput').getAttribute('type') === 'checkbox' 
使用这个function:
 function is_checkbox(selector) { var $result = $(selector); return $result[0] && $result[0].type === 'checkbox'; }; 
或者这个jQuery插件:
 $.fn.is_checkbox = function () { return this.is(':checkbox'); };