Solved

Pull data element

Posted on 2014-10-23
1
99 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

735 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