Guest User

Untitled

a guest
Jun 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. //This is a <div> that wraps around your listboxes
  2. var wrapperDiv = document.getElementById('listboxWrapper');
  3.  
  4. //Get all <select> elements within the <div>
  5. var sels = wrapperDiv.getElementsByTagName('SELECT');
  6.  
  7. //An array to store the width values
  8. var widths = new Array();
  9.  
  10. //Load the array
  11. for(var i = 0, l = sels.length; i < l; i++)
  12. widths[i] = sels[i].offsetWidth;
  13.  
  14. //Get the max width
  15. var maxW = Math.max(widths);
  16.  
  17. //Set the max width to all the list boxes
  18. for(var sel in sels)
  19. sels[sel].style.width = maxW;
  20.  
  21. var width = 0;
  22. //get the largest width
  23. $("select").each(function() {
  24. if ($(this).width() > width) {
  25. width = $(this).width();
  26. }
  27. });
  28. //make them all the same width
  29. $("select").css("width", width);
Add Comment
Please, Sign In to add comment