Are you first timer at lazacode.org? Why not join us and start exchange your knowledge with everyone. Register today!

jQuery .substr() method

0 votes
5 views
added Mar 30 in jQuery by theoh_lee Lance Corporal (790 points)
edited Apr 2 by LC Marshal

Get substring before specific character. In this example, we want to get '1345 albany street' text only from div.address-div before the comma 

<div class="address-div">1345 albany street, Bellevue WA 42344</div>

jQuery

var addy = $('.address-div').text();
var streetaddress= addy.substr(0, addy.indexOf(',')); 

Please log in or register to example this solution.

lazacode.org - Malaysia based Knowledge Exchange Platform, where you can share your finding or solution with other members of community.
...