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
精彩评论