Trying to add data to an input field

Trying to answer to this question adding data to an input field

I thought maybe useful to remind the data-* attributes.

Imagine to add to my html element having id “myElement” a customized data “data-myData”. it’d become very easy to handle the added information by JavaScript.

Here an example of js code:

<script> var myData = document.getElementById("myElement").getAttribute("data-myData") </script>

while the html element could be something like that:

<input type="text" id="myElement" value="any value" data-myData="extra information">

I hope it helps like it is useful for me.

Any better ideas or hints?