3

How to detect type of object is 'checkbox' or something else.

4 Answers 4

5

You can use is method:

if ($(this).is(":checkbox")) {
    // is checkbox
} else {
    // not checkbox
}
Sign up to request clarification or add additional context in comments.

Comments

1
$(element).attr('type') == 'checkbox'

Comments

1

You can check its type attribute. Using JQuery:

if($('input').attr('type') == 'checkbox') {
   // do if checkbox
} else {
  // do if not checkbox
}

Comments

1

You can use:

$("input[type='checkbox']").whatever();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.