Input Search size Property - Display the width of a search field in number of characters - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Search

Description

Input Search size Property - Display the width of a search field in number of characters

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Search: <input type="search" id="mySearch" size="35">

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

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

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

</body>
</html>

Related Tutorials