Javascript examples for DOM HTML Element:Input URL
Input URL name Property - Change the name of a URL field:
<!DOCTYPE html> <html> <body> Homepage: <input type="url" id="myURL" name="website"> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("myURL").name; console.log("The name of the URL field is: " + x); } function change() {/*from w w w. j av a 2s . c om*/ var x = document.getElementById("myURL").name = "newNameValue"; console.log("The name was changed to: " + x); } </script> </body> </html>