"Next" 按钮在不应该出现的时候出现

"Next" button appearing when shouldn't

我在下面有一个函数,它比较两个 selector 中的文本。如果这两个 select 或最后一次出现的相同,则 "next" 按钮将消失。目前,这不起作用。我不确定为什么会这样。仅供参考,我正在尝试 select 是一个架构 'itemprop' 并且有点不典型。

这是 fiddle - https://jsfiddle.net/carbot3000/8qjdxsz7/3/

function showHide(){
  if ( $('#areall span[itemprop="reviewBody"]').last().text().trim() == $('.review span[itemprop="reviewBody"]:visible').last().text().trim())
   {
     $('.next').hide();
  }
  else if ($('#areaall span[itemprop="reviewBody"]').first().text().trim() == $('.review:visible span[itemprop="reviewBody"]').first().text().trim())
   {
     $('.prev').hide();
  }
 }

请像这样更改您的 showHide 函数。

function showHide(){
if ( $("#areaall").children().last().index() == $("#areaall .review:visible").last().index())
  {
    $('.next').hide();
  }
  else if ($("#areaall").children().first().index() == $("#areaall .review:visible").first().index()) {
    $('.prev').hide();
  }
}

参考这个Updated Fiddle