javascript - How to grab a class name from a specific ID using jQuery -


i have id has class name such as...

<div id="nav" class="style"> 

i have array containing of ids called allids. i'm trying select id , grab class name. here have.

var grabclass = $("#"+allids[0]).map(function() {     return this.class; }); 

i expect var grabclass equal style. however, if console log grabclass says...

[prevobject: b.fn.b.init[1], context: document] 

not sure how make grabclass equal id nav's class style.

use below class name

var grabclass = $("#"+allids[0]).attr("class") 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo