There is a list of news:

<ul class="news"> <h3>News</h3> <li> <h4>28.07 15.00 – 18.00</h4> Новость 1 </li> <li> <h4>29.07 22.30</h4> Новость 2 </li> </ul> 

Go through the list and find today's date:

 $('.news').each(function(){ var ddd = $(this).find('li'); ddd.find('h4').each(function(){ var current = $(this); var string = current.text(); var last = string.substring(0, 5); if(today == last){ alert('good'); console.log(ddd.text()); }else{ alert('bad'); } }); }); 

And if today's date we deduce news, I can not catch up, how to deduce which news in today's date?

    1 answer 1

     $('.news').each(function(){ var ddd = $(this).find('li'); ddd.find('h4').each(function(){ var current = $(this); var string = current.text(); var last = string.substring(0, 5); if(today == last){ console.log(current.parent().text()); } }); });