Search code examples
javascriptmeteor

How to get before first &nbsp


I get a text from a div but I need to get before first &nbsp.How can I do.

Image.html

   <div class="progress-label">63951_1417323055238082_7899260806224854935_n.jpg&nbsp;
<span style="font-size: smaller; color: #333">59.4&nbsp;KB</span>
    </div>

I need to "63951_1417323055238082_7899260806224854935_n.jpg"

getImage.js

aracResimYolu=template.$(".progress-label").text();

Solution

  • This will extract out the image name,

    var img_name = $(".progress-label").html().split("&nbsp")[0];
    alert(img_name);
    

    JsFiddle - http://jsfiddle.net/ydzzhb0r/