Magnific Popup获取下一张幻灯片的图片标题

时间:2016-09-28 12:34:01

标签: jquery html magnific-popup

有没有办法获得下一张幻灯片的图片标题,以便我们可以在下一张/上一张箭头上显示它?

这是我在开放回调函数中编写的脚本:

      var num = $('.mfp-container .mfp-content .slide').attr('data-slideid');
      num = parseInt(num);
      console.log('current: '+num);
      var prev = num - 1;
      var next = num + 1;
      console.log('next: '+next);
      console.log('prev: '+prev);

      if(num >= 5) { console.log('next disable'); } else {
          var nextTitle = $('#explore-stay-'+next).text();
          console.log(nextTitle);

          $('.mfp-arrow-right').hover(function(){
          $('.mfp-arrow-right').html(nextTitle+' Next');
            },function(){
                $('.mfp-arrow-right').html('Next');
          });
      }

      if(num <= 0) { console.log('prev disable'); } else {
          var prevTitle = $('#explore-stay-'+prev).text();
          console.log(prevTitle);
          $('.mfp-arrow-left').hover(function(){
          $('.mfp-arrow-left').html(' Previous'+prevTitle);
            },function(){
                $('.mfp-arrow-left').html('Previous');
          });
      }

    }
  }

},itemNum); });

0 个答案:

没有答案