I need to make a bookmark which executes a javascript that changes an input value.
<input type="text" placeholder=" - " value=" - " class="test"/>
I tried several different script including this one:
javascript:(function(){var d=document,e=d.getElementsByClassName("test");e.value="new value";})();
But none of them works. Can anyone help please?
Document.getElementsByClassName()
returns an array-like object of all child elements with that class. Thus, you need to select the first index of the array. This would work: