I have recently created a gallery with navigation buttons in jQuery. As a newcomer to jQuery, I wrote a small script that adjusts the margin of a div container by a fixed amount. The script is functioning properly, but it extends beyond the top and bottom edges of the div content. While I could set a specific size for the div, my goal is to use this on multiple pages with varying amounts of content. How can I ensure that the button function does not exceed the boundaries of the content inside the div?
$('.scrolltdup').click(function(event) {
event.preventDefault();
$('.wrap').animate({
marginTop: "+=160px"
}, "fast");
});
$('.scrolltddown').click(function(event) {
event.preventDefault();
$('.wrap').animate({
marginTop: "-=160px"
}, "fast");
});
I have created a jsfiddle showcasing the page content. Any assistance would be highly appreciated. This project marks my first attempt at building a website from scratch using HTML5, CSS3, and jQuery; it's been a learning journey. :)
Thank you in advance.