Page Loading...
Run
Break Lines
Result
<!DOCTYPE html> <html> <head> <style> /*Write CSS Here*/ </style> </head> <body> <h2>Click on the button to set the input value:</h2> <input type='text' id='myInput' placeholder='Your name'> <button onclick='setValue()'>Set Value</button> <script> let val = 'Some default value'; // Invokes on button click function setValue(){ document.getElementById('myInput').value = val; } </script> </body> </html>