Input URL name Property - Change the name of a URL field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input URL

Description

Input URL name Property - Change the name of a URL field:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials