要将元素设置为只读,请使用readonly属性。您可以尝试运行以下代码以实现readonly属性-
<!DOCTYPE html> <html> <body> <h2>Login</h2> <form action = "/new.php"> <input type = "text" value = "Amit" name = "sname" readonly/><br> <input type = "password" name = "password"> <br><br> <input type = "submit" value = "Submit"> </form> </body> </html>