Input Text placeholder Property - Get the placeholder text of a text field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Input Text placeholder Property - Get the placeholder text of a text field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

First Name: <input type="text" id="myText" placeholder="Name">

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

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

<script>
function myFunction() {//from  w  w w  . j  a v a2 s.co  m
    var x = document.getElementById("myText").placeholder;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials