Jquery $ ('.article.active' ).next Issue

标签 jquery html css if-statement addclass

我得到了类似 slider 的东西,至少它应该是这样的。但是这里的代码不起作用:

$('div.app').on('click' , function(){
var current = $('.article.active');
if(current.next('.article').length > 0)  {
    current.next('.article')
        .effect("slide" ,{direction:'left', mode:'hide'},1000)
        .addClass('active')
        .removeClass('hide');
    current.effect("slide",{direction:'right',mode:'show'},1000)
        .removeClass('active')

}   else {
         $('.article:first').removeClass('hide').addClass('active');
}


});

还有 JSFiddle:http://jsfiddle.net/u4m0oLsc/ .

最佳答案

var current = $('.article.active'); 应该在点击事件函数中声明如下:

$('div.app').on('click' , function() {
  var current = $('.article.active');
  ...
}

Fiddle

关于Jquery $ ('.article.active' ).next Issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28752745/

相关文章:

javascript - 如何为移动设备使用较低分辨率的图像?

jquery - 阻止 jQuery 中的 Windows 控制键

javascript - 如何使用移动版 Safari 在客户端下载数据?

javascript - 下拉选择菜单以返回没有提交按钮的php变量

html - 从 CSS 属性 :not() doesn't work 中排除类

html - Google 字体无法在 Chrome 中正确加载

php - 如何显示附加复选框并在ajax调用后自动选中

javascript - 动态文本框jquery焦点

jquery - 如何为多个 div id 绑定(bind)单个功能

python - 使用多个参数导入 : running python script in flask