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")