How to find element type in JQuery

前端 未结 2 1672
逝去的感伤
逝去的感伤 2021-01-29 02:19

I have an array with different elements inside it. Like array contain input elements and select elements. I want to check for particular type. I tried this but it didn\'t work

2条回答
  •  无人共我
    2021-01-29 03:21

    Just use .is() to match the tag name:

    if (element.is('input'))
    

    But ideally rework the code and don't check for tag names in your loop.

提交回复
热议问题