Input URL value Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input URL


The value property sets or gets the value attribute of a URL field.

Set the value property with the following Values

Value Description
URL Sets an absolute URL

Return Value

A String, representing a URL

The following code shows how to change the URL of a URL field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
Homepage: <input type="url" id="myURL" value="">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {//w  w w .  ja  v  a2 s. com
    document.getElementById("myURL").value = "";
    document.getElementById("demo").innerHTML = 'changed';


Related Tutorials