I have a page template as follows:
<div class="page-wrapper"> <header class="header-5"> <div class="container"> content </div> <div class="background"></div> </header> <section class="content-3"> <div class="row"> <div class="col-sm-8 col-sm-offset-2 text-center"> content <a class="control-btn" href="#"> </a> </div> </div> <div class="container">
When the button is pressed <a class="control-btn" href="#"> </a>, I want it to scroll to the last <div class="container">(last line in the code snippet).
<a class="control-btn" href="#"> </a>
<div class="container">
With this jQuery, it scrolls to the first div.container(at the top of the snippet):
div.container
$('.control-btn').on('click', function() { $.scrollTo($(".container"), { axis : 'y', duration : 500 }); return false; });
How can I make it go to the next div.container (last in my code example)?
Note. The remaining elements div.containerare located below - this is not the "last" on the page.
$('.control-btn').on('click', function () { var ele = $(this).closest("section").find(".container"); // this will search within the section $("html, body").animate({ scrollTop: $(ele).offset().top }, 100); return false; });
Demo
Source: https://habr.com/ru/post/1544619/More articles:R parallel rbindlist not working - rError trying to encrypt - node.jsIs this a bug in the Visual Studio 2012 linker when using / manifest: embed? - performanceValidating data entry in an MVP pattern - c #JavaScript: Unexpected end of input ... because it only downloads part of the file? - jsonHow does Android app installation tracking work? - androidUsing trace to display the procedure in a racket - schemeReduced permutations - bashHow do you return the description of the procedure in the diagram? - schemehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1544624/running-pytest-from-inside-a-module-seems-to-cache-tests&usg=ALkJrhhYlN-HKEq_oRCV1UUOUjW3NP1jawAll Articles