Javascript DOM HTML Input Search size Property

Introduction

Change the width of a search field:

document.getElementById("mySearch").size = "50";

Click the button to change the width of the search field.

View in separate window

<!DOCTYPE html>
<html>
<body>

Search: <input type="search" id="mySearch">
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from   w w  w. j  a v a 2s .  c o  m
  document.getElementById("mySearch").size = "50";
}
</script>

</body>
</html>

The size property sets or gets the size attribute of a search field.

The size attribute specifies the width of a search field in number of characters.

The default value is 20.

The size property accepts and returns a boolean type value.




PreviousNext

Related