Using an html "data-" attribute
html, javascript
Solution
You should be able to do `this.getAttribute("data-something")`, like so:
<div id='abc' data-something='whatever' onclick='DoSomething(this.getAttribute("data-something"))></div>
or you can use `this.dataset.something`.
Here is my source
Problem
Consider a line such as this: ``` <div id='abc' onclick='DoSomething(this.id)'></div> ``` Now, suppose it's expanded to be something more like this: ``` <div id='abc' data-something='whatever' onclick='DoSomething(this.id)'></div> ``` There's no functional difference here yet, but this is my question. I'm looking for a way to pass the value of 'data-something' to the DoSomething function instead of the id. I can't seem to find a method of doing this? Is it possible? Something like the following would be nice, but of course it's not how it works. (I'm only including it to help illustrate the intended goal. ``` <div id='abc' data-something='whatever' onclick='DoSomething(this.data-something)'></div> ```