Hello-World
Hello-World

Reputation: 9555

select box won't resize

I have an issue where I have a dropdown box that is as wide as the words "choose please" but when I append to the box it adds the new options to the dropdown but is stays the same width even though the new option are much wider. How do I force it to update the width.

 var sOption = '
<option value="volvo">Volvoooooooooooooooooooooooooooooooooooo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>';

$("mySelect").append(sOption); // how do I force the width to update

Upvotes: 0

Views: 1672

Answers (2)

Featalion
Featalion

Reputation: 657

This issue is CSS-relative. By default, it works well: http://jsfiddle.net/featalion/A6qbd/. So, try to update your width style to automatic resize the select: http://jsfiddle.net/featalion/f5QWH/1/.

$('#my_select').css('width', 'auto');

Upvotes: 3

Dominic Green
Dominic Green

Reputation: 10258

This sounds like you have some css forcing the width thinner I would start with

.mySelect{width:auto;}

and go from there

Upvotes: 3

Related Questions