0

Say I have an input field WITHOUT any unique ID in an HTML form.

On focus, a new JS object related to this input will be created by a function.

Is there a way to save a reference to that object for later use without resorting to global JS variables?

Something like setting <input data-obj="#obj3247"> (just an example...actually doing it will result in data-obj="[object Object]") that ties the HTML to the JS?

MiK
  • 888
  • 3
  • 16
  • 1
    Does https://stackoverflow.com/questions/1402693/is-there-a-good-way-to-attach-javascript-objects-to-html-elements answer your question? – Thomas May 19 '20 at 14:51
  • Unfortunately no, I am not using jQuery, and I'm looking for a way to reference the object from the HTML element somehow, not the other way round. – MiK May 19 '20 at 14:54
  • Hmm, I'll have to try that out tomorrow... – MiK May 19 '20 at 14:58

0 Answers0