Select the first span element which is not empty

Viewed 5162

From a group of span elements, I want to get the values of the first occurrence of a span that is not empty.

I have this HTML

<span class="map_multi_latitude"></span>
<span class="map_multi_longitude"></span>
<span class="map_multi_latitude">30.201998</span>
<span class="map_multi_longitude">120.990876</span>

I have this Jquery before but I want to make it work such that "the first span whose text is not empty":

initialLat = $('span.map_multi_latitude:first').text();
initialLng = $('span.map_multi_longitude:first').text();

thanks in advance!

3 Answers
Related