Input Search defaultValue Property - Get the default value of a search field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Search

Description

Input Search defaultValue Property - Get the default value of a search field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Search: <input type="search" id="mySearch" value="Food">

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

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

<script>
function myFunction() {//from   www.j a  v  a2s.c o  m
    var x = document.getElementById("mySearch").defaultValue;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials