I have multiple text div containers (same class: .rocksZoom_textContainer) which I control via up/down scroll buttons. These containers are never visible together - there's a show()/hide() between them.
The code for the buttons is as follows:
$('.rocksZoom_textBox_btnUp').on('mouseenter', function(){
if ($('.rocksZoom_textContainer').scrollTop() === 0){ return; }
//
});
$('.rocksZoom_textBox_btnUp').on('mouseleave', function(){
//
});
$('.rocksZoom_textBox_btnUp').on('mousedown', function(){
if ($('.rocksZoom_textContainer').scrollTop() === 0){ return; }
//
function scroll_ContDn(){
$('.rocksZoom_textContainer').stop().animate({scrollTop:'-=50'}, 500, 'linear', scroll_ContDn);
}
scroll_ContDn();
});
$('.rocksZoom_textBox_btnUp').on('mouseup', function(){
if ($('.rocksZoom_textContainer').scrollTop() === 0){ return; }
//
function stopScroll_ContDn(){
// Stuff animated
}
stopScroll_ContDn();
});
The jQuery code for the show()/hide():
function zoomContainer_showHide(){
$(".rocksMenu_zoomContainer:visible").hide();
$(".rocksMenu_zoomContainer").eq(menuItem_place).show();
}
The HTML:
<div class="rocksZoom_textContainer">
<p>Text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text...</p>
</div>
How can I reuse the buttons functions to work on all text containers independently?
Pedro