Create an Input Hidden Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Hidden

Introduction

You can create an <input> element with type="hidden" by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">create a Hidden Input Field</button>

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

<script>
function myFunction() {//www  . j  a  va 2 s. c  o m
    var x = document.createElement("INPUT");
    x.setAttribute("type", "hidden");
    document.body.appendChild(x);

    document.getElementById("demo").innerHTML = "The Hidden Input Field created.";
}
</script>

</body>
</html>

Related Tutorials