Resources
Answers
Examples
Sign in
Get Started
What do you want to save?
Add Code snippet
New code examples
Javascript
2022-02-16 12:25:18
select element by data
If you're talking aabout the inner content of an element, this is impossible with CSS3. However, you can use this for the data attributes of an element: div [data-value="foo"] { display: block; } - GameGlitz
Add solution
Javascript
2022-01-26 18:05:03
javascript get data attribute value
var element = document.querySelector('.element'); var dataAttribute = element.getAttribute('data-name'); // replace "data-name" with your data attribute name console.log(dataAttribute);
Add solution
Javascript
2021-11-17 07:45:28
how to can i get custom data attribute value in javascript
var element = document.querySelector('.element'); var dataAttribute = element.getAttribute('data-name'); // replace "data-name" with your data attribute name console.log(dataAttribute);
Add solution
Javascript
2021-09-29 15:30:03
js get data attribute
var element = document.querySelector('.element'); var dataAttribute = element.getAttribute('data-name'); // replace "data-name" with your data attribute name console.log(dataAttribute);
Add solution
Best helpers
daily
weekly
monthly
for 3 months
John Gotti
+5
Rookie
+5
Jagoda Tajchert
+5
Jeffrywith1e
+5
show more
This website uses cookies to make IQCode work for you. By using this site, you agree to our
cookie policy
Welcome Back!
Sign up to unlock all of IQCode features:
Test your skills and track progress
Engage in comprehensive interactive courses
Commit to daily skill-enhancing challenges
Solve practical, real-world issues
Share your insights and learnings
Sign in
E-mail
Password
Recover lost password
Log in
Or log in with
Not registered?
Sign up takes less than a minute
Create a Free Account
Sign up to unlock all of IQCode features:
Test your skills and track progress
Engage in comprehensive interactive courses
Commit to daily skill-enhancing challenges
Solve practical, real-world issues
Share your insights and learnings
Sign up
Email
Password
Sign up for free
Or sign up with
By signing up, you agree to the
Terms and Conditions
and
Privacy Policy
. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.