jquery - finding the name of the element I have a reference to

前端 未结 3 1468
[愿得一人]
[愿得一人] 2021-01-22 01:13

In code I have a reference to a DOM element, in Jquery. How do I find out it\'s id? It maybe counter-intuitive, but I need to know that so I can do some manipulations on another

3条回答
  •  离开以前
    2021-01-22 01:25

    If you have a reference to a DOM element, you can simply access the ID with this.id or element.id.

    Here is a list of properties, HTMLElements have.

提交回复
热议问题