简体   繁体   中英

How to set the default value for input type number

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.

您可以使用.defaultValue实现此目的

 document.getElementById("1").defaultValue = "1"; 
 <input type="text" id="1"> 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM