jquery nodename returning undefined

后端 未结 2 1109
醉梦人生
醉梦人生 2021-01-01 09:04

This code isn\'t for anything in particular. I\'m just trying to successfully get the tagName or nodeName of an element. However, when I run the following code, I always get

2条回答
  •  心在旅途
    2021-01-01 09:50

    You are trying to access a non-member of the jQuery object. Use one of these DOM element accessors to retrieve these properties:

    $( '#last' ).get(0).nodeName

    OR

    $( '#last' )[0].nodeName

    OR

    document.getElementById( 'last' ).nodeName

提交回复
热议问题