javascript - create dropdown list with scrollbar -
i have html drop down list list of options. when user clicks on dropdown list, first 5 options scrollbar should seen. want achieve using javascript , css. i'm new these, please suggest how can show dropdown list scrollbar can able scroll , select option dropdown list. below html code:
<html> <body> <select> <option value="one">option1</option> <option value="two">option2</option> <option value="three">option3</option> <option value="four">option4</option> <option value="five">option5</option> <option value="siz">option6</option> <option value="seven">option7</option> <option value="eight">option8</option> </select> </body> </html>
with above html code, when user click on dropdown list, options seen without scrollbar.i want show first 5 options scrollbar.
try https://jsfiddle.net/ltkpshm9/ example have added jsfiddel
or use,
<select name="select1" onmousedown="if(this.options.length>5){this.size=5;}" onchange='this.size=0;' onblur="this.size=0;"> <option value="one">option1</option> <option value="two">option2</option> <option value="three">option3</option> <option value="four">option4</option> <option value="five">option5</option> <option value="siz">option6</option> <option value="seven">option7</option> <option value="eight">option8</option> </select>
Comments
Post a Comment