Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Google Docs
Each Attachment size should not exceed 1.0 MB.
Max no of attachments : 3
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
New to this Portal? Click here to
Sign up
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
jQuery
Plugins
UI
Meetups
Forum
Blog
About
Donate
All Forums
Recent Posts
Log In
Search
jQuery
Search
jQuery Forum
Move this topic
Forum :
Getting Started
Using jQuery
Using jQuery Plugins
Using jQuery UI
Developing jQuery Core
Developing jQuery Plugins
Developing jQuery UI
QUnit and Testing
About the jQuery Forum
jQuery Conferences
jQuery Mobile
Developing jQuery Mobile
Sub forum :
Move this topic
Cancel
Using jQuery
boomsnapc..
ability to access 'data' attributes without having to use .attr()
in
Using jQuery
•
11 years ago
I make use of new HTML5 data attributes to attach data to DOM elements like so:
<div class="foo"
data-randomdata="bar"
>jQuery is awesome.</div>
It would be nice to have a specific method to accessing the attributes without having to use the
.attr()
method like this:
var foo = $('div').attr('data-randomdata');
It would be nice for it to work something like this:
var foo = $('div').DOMdata('randomdata'); //equals bar
1
Replies(2)
dcherman
Re: ability to access 'data' attributes without having to use .attr()
11 years ago
There already is one, it's called .data
http://api.jquery.com/data/#data-html5
Leave a comment on dcherman's reply
keifers
Re: ability to access 'data' attributes without having to use .attr()
10 years ago
I know this is old, but as I stumbled on this: it depends which version of jQuery you are using.
1.4.3 is where you can use:
var foo = $("div").data("randomdata");
Anything prior requires the:
var foo = $('div').attr('data-randomdata');
Leave a comment on keifers's reply
Change topic type
Topic Type :
Discussions
Questions
Ideas
Problems
No of days :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Change topic type
Cancel
Link this topic
Provide the permalink of a topic that is related to this topic
Permalink
Save
Close
Reply to boomsnapclap's idea
Top
Reply
{"z1423828":[14737000002960441],"z23798773":[14737000003754293],"z8242939":[14737000002954469]}
Statistics
2
Replies
42533
Views
0
Followers
Tags
Cancel
attributes
data attribute
attr
Actions
Permalink