如何通过 JavaScript 或 jQuery 在更多输入字段中设置值(默认值)?谢谢。
<form method="" action="">
Name: <input type="text" id="id1" value="<?php $value; ?>" placeholder="Your name"> <br><br>
Surname: <input type="text" id="id1" value="<?php $value; ?>" placeholder="Your surname"> <br><br>
Email: <input type="text" id="id1" value="<?php $value; ?>" placeholder="Your email"> <br><br>
</form>
最佳答案
迭代所有输入,然后使用 element.value
语法设置默认值。
Array.from(document.getElementsByTagName("INPUT")).forEach(input => {
input.value = "Default value has been assigned";
});
Input 1: <input type="text">
Input 2: <input type="text">
Input 3: <input type="text">
关于javascript - 在更多输入字段中设置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48250651/