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

Ways to enable smooth scrolling feature in Safari

I attempted to implement smoothscroll using a polyfill by adding the following code to the bottom of my body tag: <script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e99a8486869d819a8a9b868585c ...

Decoding a JSON object in node.js

{"__v":0,"_id":{"$oid":"55f13d34258687e0bb9e4385"},"admin":true,"email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b3d6ded2c3dfd682f3d4ded2dadf9dd0dcde">[email protected]</a>","last_login":"11:25:24 AM","name ...

Executing a jQuery AJAX request to a Slim Framework PHP function with a null parameter

While working with the slim framework, I encountered an issue where a POST request to insert a record was not functioning at all. I suspect that I might be passing a parameter identified as null, which could potentially result in inserting a null record in ...

Place the image at right:0px position, but it won't display

I am trying to position an image at the end of a sentence within a div element. No matter what I try, the image always appears next to the end of my text. Here is the code I am using: <div id='xi' class='xc'>Text comes here and ...

Conflict between iOS 7+ swipe back gesture and stateChange animations

When transitioning between states in an AngularJS application, I utilize CSS animations to add visual appeal to the view change. This may involve applying fades or transforms using classes like .ng-enter and .ng-leave. In iOS 7+, users can swipe their fin ...

Stop any accidental double clicks on the <input type="submit" /> to avoid duplicate entries

Is it possible to prevent a user from clicking twice on an input tag button with type submit? I attempted using ondblclick="javascript:void(0)", but it did not work. My code is within an Html.BeginForm, not a form element tag. Thank you in advance for al ...

Arrange the table by column following a service request

Is there a method to organize the table below once it has been loaded? I am utilizing Google API to retrieve distance matrix data, but I want the table to be sorted by distance. However, this sorting should take place after the Google service call is comp ...

simplest method to brighten the image in this specific instance

I have a simple question. We are looking to enhance some static images by adding a lightening effect with an overlay. For example, when hovering over an image like on this website: (just for the lightening effect). What is the best approach to achieve thi ...

Navigating Through Secondary Navigation with Ease

In my React project, I am developing a mega-menu styled dropdown navigation. As a functional component, I am utilizing the useState hook to manage the state and control the display of sub-navigation items. The functionality of the dropdown is operational, ...

Partial views within a nested hierarchy are not updating as expected

I am currently working on a partial view that has the following structure: @model ComPost.Core.CommandsAndQueries.Contract.DataContract.FinalizeScreenDTO <div class="row"> <p> <table id="ProductTable"> <tr><td> ...

Scrolling down within a div popup using Selenium

After scrolling down in a div popup, I utilized the following command JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("arguments[0].scrollTop = arguments[1];",addToCartPopup, 250); Despite using this command successfully, I am strug ...

Tips for incorporating transitions into CSS styling

After successfully adding a picture over an element when hovering over it, I decided to include a transition: 0.2s; property but unfortunately the transition effect is not working as expected. Why is this happening? My intention is for the picture to smoot ...

Help display tooltips for ASP.NET resources using the resx string

Within my resource file, I have a string labeled Mini-move.Help. This string should be displayed each time a user clicks on the help image provided. NOTE: The help image is loaded dynamically when .HELP is added to the resource string. I am looking to cu ...

Simple Design Techniques for HTML Tables

I seem to be having trouble with the table styles when I include text in the <td> section: <td rowspan="3"> 30th May 2014 17:35... What could be the issue? <style type="text/css"> .tftable {font-size:12px;color:#333333;width:100%;borde ...

URL relative references across multiple domains

Here's a quick question: When developing themes and coding, how do you navigate linking to different files in your html/css code? For example: At our company, we mostly use <base target="http://whatever"> in our main template and then simply r ...

Error Encountered: Unable to utilize $(...).mask function with jQuery in ASP.NET using C#

I have encountered an issue while working on a task involving jQuery masked for date. When running the task in HTML, it works perfectly fine. However, when attempting to run it in ASP.NET, I face the problem where 'mask is not a function'. Below ...

Is there a way to verify whether a string is present in a ReGex even if it doesn't completely match?

My website allows users to enter a YouTube link into a text box. I want to show a checkmark icon next to the input field if the link entered is a valid YouTube URL, and a cross icon if it is not. I tried using jQuery to achieve this functionality: $(docum ...

Exploring Autocomplete Functionality with SQLite Integration in Flask

I have been searching for a solution to my problem without any success. My SQLite database contains electronic products, and I have a search box that allows users to search for products by typing in their name. However, I want to enhance the user experienc ...

How to keep all tabs closed at the beginning with jQuery Accordion

Struggling to create a FAQ Accordion with a hover effect that opens and closes the description, but having difficulty keeping all tabs initially closed. I've tried setting collapsible to true and active to false without success. Can anyone provide ass ...

Exploring methods to retrieve specific data from a JSON object by utilizing the $.each() function

I've been attempting to access specific values from a JSON file using the key lat as I iterate through each entry. Unfortunately, I keep receiving an undefined result when attempting to print them. JSON Data [{"pid":4317129482,"lat":"51.5078","lon": ...