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

Javascript examples for DOM HTML Element:Input Search

Description

Input Search placeholder Property - Get the placeholder text of a search field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="search" id="mySearch" placeholder="Search for something..">

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

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

<script>
function myFunction() {/*from  ww  w.  j a  v a  2s . c om*/
    var x = document.getElementById("mySearch").placeholder;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials