"Keep scrolling through the div's content and then proceed with the

My layout consists of a div container that occupies 80% of the screen, with fixed sidebars on both the left and right taking up 10% each. The content within the div is quite large, so I've applied overflow: hidden to it in order to hide excess content. However, when users scroll down, the scrolling action bypasses the div and only affects the body.

If I change the div to overflow: scroll, users will initially scroll within the div, but then scrolling abruptly stops without affecting the body.

I've also observed that hovering over the overflow: scroll div enables scrolling, while hovering over the fixed sidebars causes the body to scroll instead.

This behavior is not ideal for my requirements. What I'm aiming for is for the hidden div to scroll from top to bottom first, and then for the body to start scrolling once the end is reached.

In an attempt to achieve this, I have tried detecting when the div container reaches the top and using $(#myDiv").focus(), but even then, if the mouse hovers over the sidebars, the body still scrolls.

Is there a solution to make this work as intended? Particularly with overflow:hidden, it seems like scrolling is restricted.

You can view an example at codepen.io/OrvaldMaxwell/pen/Yraryb where I need the "scrollMeAutoPLS" div to scroll first before transitioning to scrolling the body.

Answer №1

Here is a straightforward way to do it:

$('#yourDiv').animate({ scrollTop:$('#yourDiv')[0].scrollHeight },800,function() {
    $('html,body').animate({ scrollTop:$(document).height() },800);
});

The value of 800 represents the duration in milliseconds.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Rapid processing of JavaScript upon page load

I recently implemented a dark mode feature on my WordPress site. Here are the four modes I included: 1- Automatically based on user's system settings 2- Light mode 3- Semi-lit mode 4- Dark mode The implementation is in place and functioning perf ...

Having trouble with Semantic UI Modal onShow / onVisible functionality?

Seeking assistance with resizing an embedded google map in a Semantic UI modal after it is shown. After numerous attempts, I have narrowed down the issue to receiving callbacks when the modal becomes visible. Unfortunately, the onShow or onVisible functio ...

What is the best way to emphasize a column starting from the top and going down to the nth row

I'm working on a task to highlight columns and rows in a table from the top to the selected cell and from the left to the selected cell. Currently, I have achieved highlighting both the whole column and row. Here is an image of the desired outcome: ...

What could be the reason that the painting application is not functioning properly on mobile devices?

I am facing an issue with my painting app where it works perfectly on desktop browsers but fails to function on mobile devices. I tried adding event listeners for mobile events, which are understood by mobile devices, but unfortunately, that did not solve ...

Tips for utilizing div as a dropdown menu

I have a challenge with the following code and I am looking to make it function like a dropdown one by one For example: ABCD ABCD 1234 ABCD 1234 abcd <ul class="first"> <li class="first-a"><a href="https://someurl">ABCD&l ...

No image upload possible until 'submit' button is clicked

I'm attempting to send an mp3 file to the server using AJAX without the need for a submit button, but I'm facing an issue where the file isn't getting uploaded. Can anyone help me pinpoint the mistake in my code? <script> $(document). ...

The image wrapping feature within a div element will only function properly when there are more than one line of text present

I have come across a strange issue that I am struggling to solve. I have an image within a div with the float: left; attribute, but this styling only seems to work when the div has more than one line of text. When the div contains just one line, it ends ...

Collect data from website submissions via email

Is it possible to receive the results via email when someone submits their details on my site using a script? My server does not allow .php or .asp files, only .css. How can I achieve this? ...

Change a portion of the CSS background-image URL using vanilla JavaScript for a set of pictures

My current code successfully updates part of an src URL for regular images. let svgz = document.querySelectorAll(".svg"); for (let i = 0; i < svgz.length; i++) { svgz[i].src = svgz[i].src.replace("light", "dark"); } Now, ...

Trigger bootstrap dropdown when input is clicked

One of the challenges I'm facing is getting a Bootstrap 4 dropdown to open when a user tabs to it for ADA accessibility. Currently, clicking on the input triggers the dropdown to show, but I need it to work with tabbing as well. Using a focus event a ...

What is the best way to show both the input and output on one page?

I have a single PHP file with two separate PHP tags. When I click on the first row in the table of the first PHP tag, I want to display the value of the first row in the table of the second PHP tag on the same page. The common field for both tables is or ...

Using Javascript to Divide Table into Separate Tables each Containing a Single Row

Is there a way to divide the content of this table into three separate tables using JavaScript? It is important that each table retains its header information. Unfortunately, I am unable to modify the id's or classes as they are automatically generat ...

Adding a combination of HTML and Javascript to an element can result in unexpected behavior

http://jsfiddle.net/PeKdr/ Encountering an issue when having a JavaScript variable that contains both HTML and JavaScript, resulting in unexpected behavior in the output window. Neither of the buttons - one triggering the function appendTheString() or the ...

Utilize Bootstrap to ensure that column size remains consistent at 12 on small devices, while maintaining default behavior on larger devices

I have a component that has the ability to hold any number of elements. My goal is to have the elements stack on top of each other and take up the full width of the container when the screen is small, but revert to the default Bootstrap column behavior on ...

Changing the Title of UI Tabs

I am facing an issue with setting the title in tabs, as the title is appearing behind the background. If I set background: transparent; in the #tabss .ui-tabs-nav class, then my title shows up properly. Otherwise, it gets displayed behind the background. ...

Problem with repetitive looping of Jquery click event within an Angular controller

Currently, I am in the process of creating an app using onsen UI (angular based) + phonegap. One issue I am facing is related to a JQuery click event inside an angular controller. The problem arises when I navigate back through the page stack and then ret ...

What is the best way to achieve a column layout using Bootstrap?

I'm having difficulty adjusting the column width in Bootstrap columns to my specific needs. Check out this link for more information: : https://i.sstatic.net/Tvdef.png What I'm trying to achieve is to keep the label column width fixed while all ...

What is the reason behind my phone burger not working and how can I resolve the problem?

I am facing an issue with the burger menu icon on my website. When I click on the burger icon, it doesn't transform into a cross as intended. Even though I can see that the class .active is being added in the DOM, the menu doesn't respond to the ...

Transform the entire content with a simple click on input labels

tab3 > brand-sidebar-wrapper > lacquer-type-wrapper > input Whenever I click on the input labels, the .content div moves to the top and leaves a lot of space at the bottom. I have attempted to modify the JavaScript code, but the issue seems to b ...

Steps to enable the click feature on a table-responsive column within innerHTML

I'm encountering an issue with displaying DataTable content in a div on my page using the code snippet below: $('#' + divid + '-data')[0].innerHTML = data.TableContent; The TableContent is retrieved from a different method and lo ...