I've created a dropdown that has issues resizing according to what's selected. I'm using the following stackoverflow answer as inspiration to resize my dropdown: https://stackoverflow.com/a/20091985/3166468
For some reason, although the resizing happens, it always resizes either too much or too little. Here's the jsFiddle: https://jsfiddle.net/yadhwb97/3/
This is the HTML:
<div class="dropdown">
  <select id="real_dropdown">
    <option disabled="">Options</option>
    <option value="long">Something super long in here</option>
    <option value="short">Short</option>
  </select>
</div>
<select id="width_tmp_select">
  <option id="width_tmp_option"></option>
</select>
And this is the jQuery:
$(document).ready(function() {
  $('.dropdown').change(function(){
    $("#width_tmp_option").html($('.dropdown option:selected').text()); 
    $(this).width($("#width_tmp_select").width()+30);  
  });
});
When you select the dropdown options, you'll see how it resizes either too much or too little. How can I make the resizing work correctly?
 
     
     
    