Javascript DOM HTML Input URL form Property get

Introduction

Return the id of the form containing the <input type="url"> element:

var x = document.getElementById("myURL").form.id;

Click the button to display the id of the form the url field belongs to.

elements with type="url" are not supported in Safari.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form id="myForm">
  Homepage: <input type="url" id="myURL">
</form>/*from ww w  . j av a2 s .c  o m*/
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myURL").form.id;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The form property returns a reference to the form containing the URL field.

This property returns a form object on success.

This property is read only.

If the URL field is not in a form, null is returned




PreviousNext

Related