Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Pull data element

Posted on 2014-10-23
1
Medium Priority
?
109 Views
Last Modified: 2014-10-23
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
0
Comment
Question by:tonelm54
1 Comment
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 40399555
use:
data-folderid
and :
alert($(this).data("folderid"));

no uppercase, right.
More infos here :
http://www.w3.org/TR/2011/WD-html5-20110525/elements.html#embedding-custom-non-visible-data-with-the-data-attributes
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question