<html>
<head><style>body {min-height: 300px;} input { font-size: 16px; } textarea { font-size: 16px; } </style></head>
<body>
<input id="usernameInput" type="text" placeholder="Username">
<button onclick="register()">Register</button>
<script>function register() {
document.getElementById("usernameInput").value = "";
}</script>
</body>
</html>]]>- It removes the text inside the input field and shows the
placeholder
attribute's value - It updates the
placeholder
attribute Setting an input's value to an empty string will remove the text inside the input field and show the placeholder
attribute's value.