Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is a <div> that wraps around your listboxes
- var wrapperDiv = document.getElementById('listboxWrapper');
- //Get all <select> elements within the <div>
- var sels = wrapperDiv.getElementsByTagName('SELECT');
- //An array to store the width values
- var widths = new Array();
- //Load the array
- for(var i = 0, l = sels.length; i < l; i++)
- widths[i] = sels[i].offsetWidth;
- //Get the max width
- var maxW = Math.max(widths);
- //Set the max width to all the list boxes
- for(var sel in sels)
- sels[sel].style.width = maxW;
- var width = 0;
- //get the largest width
- $("select").each(function() {
- if ($(this).width() > width) {
- width = $(this).width();
- }
- });
- //make them all the same width
- $("select").css("width", width);
Add Comment
Please, Sign In to add comment