javascriptjquerycsshtml-selectcontent-length

How to expand 'select' option width after the user wants to select an option?


Maybe this is an easy question, maybe not. I have a <select> box where I hardcode the width to 120px:

<select style="width: 120px">
  <option>REALLY LONG TEXT, REALLY LONG TEXT, REALLY LONG TEXT</option>
  <option>ABC</option>
</select>

I want to be able to show the second option so that the user can see the full length of the text.

Like everything else. This works fine in Firefox, but doesn't work with other browsers for me.


Solution

  • If you have the option pre-existing in a fixed-with <select>, and you don't want to change the width programmatically, you could be out of luck unless you get a little creative.

    If you are adding a long option later through JavaScript, look here: How to update HTML “select” box dynamically in IE