I want to extract the text from the first child small
element inside a dynamically generated div
. The structure looks like this:
<div class="NDateCount" style="display:inline-block">
<!--Issue to solve-->
<small style="display:none;" class="ng-binding">2017-07-08T12:44:10.367+06:00</small>
<small ng-show="CountPostDate(post.timelineStrore.creationDate) < 2" style="color:#1ab394;" class="ng-binding"><i class="fa fa-clock-o"></i> 3 hours ago</small>
<!--End of Issue to solve-->
</div>
I have multiple instances of this div being generated and I am trying to retrieve the content of the first small
element using jQuery. So far, my code looks like this:
var ReloadTime = function () {
$('.NDateCount').each(function () {
var OldValue = $(this).first().text();
alert(OldValue);
});
setTimeout(ReloadTime, 50);
}
However, this function is capturing the text from both small
tags instead of just the first one as shown in this image:
Image link: https://i.sstatic.net/VOIFe.png
Is there a way to fix this issue?