Reputation: 839
In my form has four DropDown list controls, I want to set width for one of the control as 200px using Jquery. Because this control's value dynamically change and dont know how length is. How to do this? with IE8.
Upvotes: 0
Views: 4808
Reputation: 1274
If you don't know the length of the options then you could just set width: auto;
and let it size accordingly. But if you do need to set it to 200px though use:
$('your-selector').css("width", 200);
Upvotes: 0
Reputation: 103365
One option is to use width
$('#selectId').width(200);
or CSS:
$('#selectId').css({'width': 200});
Upvotes: 1
Reputation: 38102
You can use change() event to keep track when the value of your select has been changed and use width() to set the width of it:
$('#dropDownId').change(function() {
$(this).width(200);
}).change();
Upvotes: 0
Reputation: 5314
It will help if you post your HTML but you can do it like this:
$("#idOfMyDropdown").css("width", "200px");
Upvotes: 0