开发者

Why this jquery selector giving uncaught exception: in firefox

开发者 https://www.devze.com 2023-02-07 23:09 出处:网络
I\'m populating the results div with images from jsonp call. The images are displayed like <li><img class=\"abs\" src\"...\"/></li>

I'm populating the results div with images from jsonp call. The images are displayed like

<li><img class="abs" src"..."/></li> 
<li><img class="abs" src"..."/></li> 
<li><img class="abs" src"..."/></li> 
...

I'm using the following jquery code to do a simple task such as displaying the tag name when an image with .abs is clicked on This should return IMG. But instead i am getting uncaught exception: Syntax error, unrecognized expression: # in firefox firebug. What am i doing wrong.

$('.abs').开发者_开发技巧live('click',function(){
    console.log(this.nodeName);
});


Did a quick search and this came up: jquery nodename returning undefined

From that post:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消