Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

HTML DOM Input Color Form Property



The Input Color form property returns the reference of enclosing form for input color.

Syntax

Following is the syntax −

  • Returning reference to the form object
inputColorObject.form

Example

Let us see an example of Input Color form property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input Color Form</title>
</head>
<body>
<form id="formForColorsInput">
Color Picker: <input type="color" id="Color" >
</form>
<button onclick="getFormID()">Get Form ID</button>
<div id="divDisplay"></div>
<script>
   function getFormID() {
      var inputColor = document.getElementById("Color");
      var divDisplay = document.getElementById("divDisplay");
      divDisplay.textContent = 'Form ID for color input: '+inputColor.form.id;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘Get Form ID’ button −

After clicking ‘Get Form ID’ button −

Updated on: 2019-07-30T22:30:26+05:30

105 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements