Javascript examples for DOM HTML Element:Input URL
The defaultValue property sets or gets the default value of a URL field.
The default value is the value specified in the HTML value attribute.
You can use defaultValue property to find out whether the URL of a URL field have been changed.
Set the defaultValue property with the following Values
Value | Description |
---|---|
value | Sets the default value of the URL field |
A String, representing the default value of the URL field
The following code shows how to change the default value of a URL field:
<!DOCTYPE html> <html> <body> Homepage: <input type="url" id="myURL" value="http://www.google.com"> <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// w ww . j a va 2 s. c om var x = document.getElementById("myURL"); x.defaultValue = 'new value'; } </script> </body> </html>