“下一个"不应出现的按钮 [英] "Next" button appearing when shouldn't

查看:147
本文介绍了“下一个"不应出现的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面有一个函数,用于比较两个选择器中的文本.如果这两个选择器的最后一次出现相同,则下一步"按钮将消失.目前,这是行不通的.我不确定为什么会这样.仅供参考,我要选择的是模式"itemprop",有些不典型.

I'm have a function, below, that is comparing the text in two selectors. If the last occurrence of both of these selectors is the same, the "next" button will disappear. Currently, this is not working. I'm not sure why this is happening. Just fyi, what I'm trying to select is a schema 'itemprop' and is somewhat atypical.

这是小提琴- 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

这篇关于“下一个"不应出现的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆