【问题标题】:jquery hide element in scrolljquery在滚动中隐藏元素
【发布时间】:2013-10-26 20:06:03
【问题描述】:

我创建水平滚动条来左右移动内容内的元素,我的脚本是这样的:

<script>
jQuery(document).ready(function() 
{
var $item = jQuery(".productos_items"), 
visible = 3, 
index = 0, 
endIndex=($item.length/visible)-1; 

jQuery('#productos_arrowR').click(function(){
if(index < endIndex ){
index++;
$item.animate({'left':'-=100px'});
}
});

jQuery('#productos_arrowL').click(function(){
if(index > 0){
index--;            
$item.animate({'left':'+=100px'});
}
});
});
</script>

我尝试这样做:

if ($item>=visible)
{
jQuery(".productos_items").css("display","none")
}

但没有工作

问题是我无法隐藏元素,例如我放了前 3 个可见的项目,然后我想隐藏其他的,当推到右边时显示这个并隐藏另一个

我尝试了不同的东西,但我最终无法得到这个

谢谢

【问题讨论】:

  • 没有什么可以帮助我?

标签: javascript jquery jquery-animate jquery-scrollable


【解决方案1】:

试试这个:

if ($item.length >= visible)    {
    $item.hide()
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-24
    • 2014-11-28
    • 1970-01-01
    • 2023-03-29
    • 2017-08-28
    • 2021-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多