Reputation:
I have one input field having type number. I want to set its default value to 1. I have tried using defaultValue attribute in various ways but nothing worked for me. Is there any solution to set the default value using html or ReactJS.
Upvotes: 0
Views: 3355
Reputation: 95
You can achieve this by using .defaultValue
document.getElementById("1").defaultValue = "1";
<input type="text" id="1">
Upvotes: 1