i can't figure out how to set a value using javascript.
Here is how the HTML look like:
<input type="text" name="cardholderName" data-bind="value: creditCardForm.name,
css: creditCardForm.style.name" maxlength="30">
When i try to set the value in the Chrome console
document.getElementsByName('cardholderName').value="myname";
The console returns "myname" but the field in the browser isn't populated with this approach. Any hints on what is missing? Thanks
getElementsByName
returns an array, and there is no property value
on an array. I think you mean to get the first item:
document.getElementsByName('cardholderName')[0].value="myname";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.