Unable to Trigger Jquery Scroll Event

I'm trying to figure out why a div is not appearing when the page is scrolled down. The issue is that my page body and most other elements have overflow hidden, except for a table that appears at a certain point on the page when a button is pressed. This table has overflow:scroll applied to it, and I've attempted to attach a scroll event to it. However, it doesn't seem to work. Any ideas on what could be causing this?

Here's my HTML:

<body>  
  <div class="maine">
<table id="tableToClone" class="ts">
  <div class="backtotopplank"></div>
                    </table>  
  </div>   
</body>

CSS:

html, body{
  height:100%;
  background:black;
  width:100%;
}

.ts  {  
  background:red;
    border-collapse:collapse;
    border-spacing:0;
  margin:auto auto;
    width:70%;
  height:3000px;
    overflow:scroll;
}


.maine{
  width:70%;
  margin:auto auto;
  background:white; 
  position:relative;
    overflow-x:hidden;  
}

.backtotopplank{
    background:black;
    background-size:100% 100%;
    position:fixed;
    width:153px;
    height:56px;
    left:900px;
    bottom:0px;
    cursor: pointer;
display:none;
}

And JQuery:

$(".ts").scroll(function() {
  var y = $(this).scrollTop();
  if (y > 400) {
    $(".backtotopplank").fadeIn();
  } else {
    $(".backtotopplank").fadeOut();
  }
});

Answer №1

$(document).ready(function()
{
  $(window).scroll(function() {
    var y = $(this).scrollTop();
    if (y > 100) {
     $(".backtotopplank").fadeIn();
    } else {
     $(".backtotopplank").fadeOut();
   }
  });
});

Give this a try, it worked wonders for me!

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

Display the contents in a textarea with modal, not as a string

I'm currently working on implementing a modal overlay window with simplemodal that will display the contents of a text area. My goal is to show the rendered output rather than just the string value. For example, if a user enters HTML or includes an im ...

HTML5 Advanced API Integration with Vimeo

After setting up my Vimeo account and app for video upload, I received approval. However, when I attempted to upload a video to the Vimeo server, I encountered difficulties. I am struggling to understand how OAuth functions. Please see below for the co ...

Displaying text and concealing image when hovering over a column in an angular2 table

I am currently using a table to showcase a series of items for my data. Each data entry includes an action column with images. I would like to implement a feature where hovering over an image hides the image and reveals text, and vice versa (showing the im ...

Using Jquery fadeIn along with responsive CSS media queries

Issue at Hand: An issue arises with my navigation bar and text block animations. The fading effect applied on the text element causes inline styles to be added, thus disrupting the media query set to hide the text on smaller screens. If you disable the s ...

Resolving Uncaught TypeError in React when trying to read properties of undefined (specifically 'map')

As a newcomer to React and API usage, I am facing difficulty resolving the error below. My goal is to showcase a carousel of images using React.js but encountered this issue: Error message: Popular.jsx:26 Uncaught TypeError: Cannot read properties of unde ...

Using Joomla 2.5 and mootools for ajax - passing parameters to a component

After countless hours of searching for a solution to this persistent issue, I find myself stuck with the following code in a standard component along with its controller: defined('_JEXEC') or die; jimport('joomla.application.component.cont ...

Tips for getting the setInterval function to work with a progress bar even when a tab is not in focus

After browsing through similar questions, I couldn't find the answer I was looking for. As a newbie in programming experimenting with JavaScript Progress Bar, I encountered an issue where the progress bar would pause and the counter wouldn't coun ...

Javascript eval function providing inaccurate results

I have encountered a problem while using eval() for a calculator I am developing. When I input the following code: console.log(eval("5.2-5")); The output is: 0.20000000000000018 I am confused as to why this is happening. Thank you for your assistance. ...

What is the best way to convert API data into a currency format?

Hello, I need assistance with formatting data retrieved from an API into a currency format. The code below successfully retrieves the data but lacks formatting. For instance, if the data displays as 100000000, I would like it to be formatted as IDR100.000. ...

JavaScript salary calculation function not functioning properly

Once the user inputs the employee's name and the number of hours they worked on the HTML form, the submit button captures this information and stores it in variables for calculating their pay. The script also factors in overtime pay. Despite feeling l ...

Clicking a button to reference a specific section within a list item

I'm currently working on developing a todo application using php, ajax, and mysql. I am facing a challenge where I need to implement a button that deletes an item from both the screen and the database. However, I am unsure about how to specify which i ...

JavaScript Challenge: Calculate the Number of Visible Characters in a Div

I have a div with text content (a string of length S) that is fixed in size but can be of any length. When the text exceeds a certain point (referred to as L), it gets truncated, and the portion beyond that limit becomes invisible. In other words, characte ...

unable to receive JSONP response through JQuery AJAX

How can I make a cross-domain request to invoke a REST service using Jquery ajax? Here is the code snippet I am currently using. The variables ad1, city, sp, pc, and cn are retrieved using getElementById: url='http://admin:admin@*******:***/rest/aru ...

Unshrinkable item causing multiple lines text-overflow in a flexbox layout

My goal is to achieve the following design: https://i.stack.imgur.com/YLUtN.png Currently, I have attempted the following approach (although it doesn't fully meet my requirements): .parent { max-height: 40px; display: flex; flex-wrap: wrap; ...

Organizing Pictures in a Gridded Design

My dilemma lies in displaying a set of thumbnail images within a div. The width of the div can vary depending on the screen size. Each image is fixed at 150px * 150px with a padding of 5px. I aim to arrange these thumbnails in a grid layout while ensuring ...

Submitting forms using AJAX in Django

I am getting a 'Not Ajax' response every time I try to submit my form. There must be something small that I'm overlooking... class VideoLikeView(View): def post(self, request): if request.is_ajax(): message = 'Aj ...

`Hovering over a div triggers a continuous animation loop`

I've gone through various questions and solutions related to this issue, but unfortunately, none of them seem to work for me. It's possible that I might be overlooking something or my scenario is slightly unique. The main problem I'm facing ...

The Power Duo: jQuery Form Plugin paired with jQuery Validate

Have you ever tried using the jQuery Form Plugin in combination with the jQuery Validate plugin? The issue I'm facing is that even when the required fields are empty, the form still submits via AJAX. Check out my code snippet below: // Making the ne ...

Is there any way to extract the source files from a compiled Electron application?

Is there a way to extract the contents of a .app Application developed using Electron for Mac OS? I'm eager to explore the underlying source files, but I'm not familiar with the procedure to access them. Any assistance would be greatly appreciate ...

Dynamic text input and selection menu with AJAX (PHP and JavaScript)

As a student who is new to Javascript and PHP, I am trying to create a login page for my website that can verify user input in the database using AJAX. For example, when a user enters their username and password, the system should automatically check if t ...