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

前端 未结 3 1466
[愿得一人]
[愿得一人] 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:33

    If you want the id then you can use

    $("youelementselector").attr("id");
    

    and if you want elements name then

    $("youelementselector").attr("name");
    

    See attr

提交回复
热议问题