2
    <div id="job" data-job-id="3054>jobs status</div>

How to get the value of data attribute value in the above node.

2
  • where do you need to get these values? Commented Dec 12, 2016 at 16:33
  • Need the data-attribute value in the react entry point file, which should be rendered in the index.html Commented Dec 12, 2016 at 16:39

2 Answers 2

4

Just use the javascript .getAttribute() method.

var val = document.getElementById('job').getAttribute('data-job-id');

Sign up to request clarification or add additional context in comments.

Comments

1

As better solution

console.log(e.target.dataset.job-id)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.