Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Pull data element

Trying to do a simple task of pulling the value out of the data element, which I thought would be easy, but obviously not. To simplify my issue, Ive got the following HTML code:-
<div id="divMenu">
    <div data-folderID="4" class="menuTopItem">Operational</div>
    <div data-folderID="5" class="menuTopItem">Administrative & Accounting</div>
    <div data-folderID="6" class="menuTopItem">Time Sheets</div>
    <div data-folderID="7" class="menuTopItem">Interface</div>
    <div data-folderID="8" class="menuTopItem">Setup</div>
</div>

Open in new window


And then to simply pull out the value:-
$(document).ready(function () {
    $('.menuTopItem').click(function (e) {
        alert($(this).data("folderID"));
    });
});

Open in new window


However I keep getting 'undefined', and I cannot figure out why, does anyone have any ideas?

Ive put it onto jsFiddle in the hope someone can point out the error of my ways.

Thank you in advance
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial