If you are using jQuery (you should tag your question with jquery tag) then you want to use such a solution using $.ajaxComplete . If you use a different infrastructure, there are other ways to do it the same way.
$(document).ajaxComplete(function() { $(".results .date").each(function() { var strong = $('<strong>').text($(this).text()); $(this).empty().append(strong); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="results"> <div class="article"> <div class="date">jan 8, 2013</div> <p>Some content here</p> </div> <div class="article"> <div class="date">feb 8, 2013</div> <p>Some content here</p> </div> </div> Test: <button onclick="test()">Trigger JQuery Ajax Complete Event</button>
The only way to detect a change in the results is either A) to make an assumption based on the result saying that it promises a new one or B) comparing it with the previous version. You can use $.ajaxSend to save the changes for method B.
If you go by method A , you can just keep track of the maximum date and do something only if the date is longer, and then update the maximum date with this.
source share