To achieve scrolling after clicking on a specific div class using jQuery, you can use the scrollTop() method. Here's an example:

HTML:

<div class="myDiv">
  <!-- Content goes here -->
</div>

JavaScript (jQuery):

$(document).ready(function() {
  $('.myDiv').click(function() {
    $('html, body').animate({
      scrollTop: $(this).offset().top
    }, 800); // Adjust the animation speed as needed (in milliseconds)
  });
});

In the above code, we attach a click event handler to the elements with the class "myDiv". When any element with that class is clicked, it will scroll the page to the top of that element using the animate() method with the scrollTop property.

Make sure you have included the jQuery library in your HTML file

locomotive scroll i want to scroll after click on div class with jquery lang

原文地址: https://www.cveoy.top/t/topic/hNaj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录