如何检测对象的类型是“复选框”或其他内容。
答案 0 :(得分:5)
您可以使用is
方法:
if ($(this).is(":checkbox")) {
// is checkbox
} else {
// not checkbox
}
答案 1 :(得分:1)
您可以检查其类型属性。使用JQuery:
if($('input').attr('type') == 'checkbox') {
// do if checkbox
} else {
// do if not checkbox
}
答案 2 :(得分:1)
$(element).attr('type') == 'checkbox'
答案 3 :(得分:1)
您可以使用:
$("input[type='checkbox']").whatever();