Calculate width of div proportionally to text inside in jquery?
<p>I've built this no-so-great piece of javascript to calculate the width of a div based on the number of characters by increments.</p>

<pre><code>  $(".tweet-text").each(function() {
  var tweetText = $(this);
    if(tweetText.text().length &gt; 30) {
      tweetText.css("width", "200px");
    }
    if(tweetText.text().length &gt; 60) {
      tweetText.css("width", "240px");
    }
     if(tweetText.text().length &gt; 80) {
      tweetText.css("width", "280px");
    }
    if(tweetText.text().length &gt; 100) {
      tweetText.css("width", "310px");
    }
    if(tweetText.text().length &gt; 120) {
      tweetText.css("width", "360px");
    }
    if(tweetText.text().length &gt; 130) {
      tweetText.css("width", "400px");
    }
  });
</code></pre>

<p>Is there a way to calculate the width of tweetText exactly and proportionally to the number of characters ?</p>

<p>Thanks!</p>
