I am wondering if it is possible to modify the HTMLInputElement to display something other than a value that returns a value.
Why? Well, sometimes you want to show the user something nice, like a string , but you want to publish the ID on the server. If you use several logic / plugins at the input, this starts problematic with using an additional fake one. So why not include both in one ?! =)
I already noticed that you can define a getter for value prop. But I am losing the functionality of the subscriber setter, which will change the displayed text. = /
HTML:
<input id="foobar" type="text"/>
JS:
var input = document.getElementById('foobar'); input.value = 'Mr. Foo Bar'; input.myHiddenValue = 123; Object.defineProperty(input, 'value', { get: function(){ return this.myHiddenValue; } });
So if you can tell me if it's possible and keep the native setter or just a stupid late night idea let me know xD
Mohre source share