0

How can I console.log the data-text value in that javascript file? Noob here still learning. Thanks for the help or information..

Sample: <script type="text/javascript" src="./test.js" data-text="Hello World"></script>

RedeeMe
  • 55
  • 6

1 Answers1

1

You could use document.querySelector() combined with the Attribute Selector to select the script like so

document.querySelector('script[data-text]').dataset.text
caramba
  • 21,282
  • 18
  • 84
  • 125