finding the type of an element using jQuery

前端 未结 3 554
慢半拍i
慢半拍i 2020-11-27 09:38

In jQuery, if I have a reference to an element, how can I determine what kind of element it is, for example, an input or an dropdown? Is there any way to find out?

3条回答
  •  Happy的楠姐
    2020-11-27 10:04

    You can use .prop() with tagName as the name of the property that you want to get:

    $("#elementId").prop('tagName'); 
    

提交回复
热议问题