iam_peter
iam_peter

Reputation: 3924

jquery map() function returns undefined

i got a problem with the map function, maybe i got it wrong. i have a menu that consists of div layers (here is one item)

<div class='menu_item inner_node' hash='4' depth='0'>Portfolio</div>

if some one click it the css class selected is added to that item. now i want to get all selected menu items with map() like this:

$("div.selected").map(function()
{
    return $(this).attr("hash");
}
).get().join(", ");

i just need the "hash" attribute from it. i made an example here: Example the output is undefined everytime... what is wrong with the script?

regards, peter

Upvotes: 0

Views: 805

Answers (1)

Dogbert
Dogbert

Reputation: 222108

You're missing a return in function get_hash().

http://jsfiddle.net/gruhH/1/

Upvotes: 3

Related Questions