title: How to select a text from a class to fit the with of the div?
body: <p>Based on the following code I want to know how can I select the biggest text that fits in the width I define in CSS?</p>
  
  <p>Now it is showing all texts but is showing only 200px of the text because this is what I've defined.</p>
  
  <p>In future I will have a XML file where I have multiple texts and I thing by AJAX call I will read that file.</p>
  
  <p><a href="https://jsfiddle.net/a06cu92t/" rel="nofollow">https://jsfiddle.net/a06cu92t/</a></p>
  
  <pre><code>$(".places").each(function (index, item) {
      var obj = $(item).find("span");
      if (obj.length) {
          var placename = $(obj).text();
          if ($(obj).width() &gt; $(item).width() &amp;&amp; placename.trim().length &gt; 0) {
              var limit = 0;
              do {
                  limit++;
                  placename = placename.substring(0, placename.length - 1);
                  $(obj).text(placename + "...");
              } while ($(obj).width() &gt; $(item).width() &amp;&amp; limit &lt; 1000)
          }
      }
  });
  </code></pre>