I am trying to change the width of a drop down list depending on the content by using javascript.
Example see amazon's drop down list in the first page in search section. http://www.amazon.com/ref=gno_logo
Can anyone help me?
I am trying to change the width of a drop down list depending on the content by using javascript.
Example see amazon's drop down list in the first page in search section. http://www.amazon.com/ref=gno_logo
Can anyone help me?
Amazon uses another <span>
element overlayed on top of the <select>
which has its content changed to fit the select
menu's value - and it uses width: auto
on this tag to fit it to its contents.
So in effect, the drop-down list in Amazon is hidden while a "fake" drop-down in the form of a separate span
takes its place.