简体   繁体   中英

jquery hide element in scroll

I create horizontal scroller for run to the left and right the elements inside content , my script it´s this :

<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>

I try something as this :

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

But no works

The problem it´si can´t get hide the elements , for example i put visible first 3 items and after this i want hide the others and when push to the right show this and hide the other

I try different things but i can´t get this finally

Thank´s

try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM