简体   繁体   中英

check ul having li with specific class, jQuery

I am trying to check ul or li elements whether have specific class every 5 seconds as folllows, but i am not getting result.

window.setInterval(function(){
  var a = $('ul li .current_page_item a').text();
  alert(a);
}, 5000);

how to do it ??

Remove the space between class selector and li otherwise, it may search for element with that class inside li .

window.setInterval(function(){
  var a = $('ul li.current_page_item a').text();
  // -------------^-------- here
  alert(a);
}, 5000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM