ScrollTop inside css scrollbar (overflow-y: auto)$(window).scrollTop() vs. $(document).scrollTop()Get text selected and update himJquery readmore function not working correctlyHow can I put <br> tag in <td> contents with JQuery?How to get only text from html tagFind and wrap SPAN around all selected words in a DIVAdd class to iframe inner body when parent body hasclassHighlighting a text from string by using sub-string methodGet the startoffset and endoffset of a string from a stringHow to capitalize all the chars of string after . like mobile keyboard
Should I inform my future product owner that there are big chances that a team member will leave the company soon?
Who are the people reviewing far more papers than they're submitting for review?
How to generate short fixed length cryptographic hashes?
Very lazy puppy
Beauville-Laszlo for schemes
How can I draw overlapping triangles?
Random restarts for unsatisfiable problems
Have you ever been issued a passport or national identity card for travel by any other country?
Why 1.5fill is 0pt
Are lay articles good enough to be the main source of information for PhD research?
Transit visa to Hong Kong
Latex matrix formatting
Which version of the Pigeonhole principle is correct? One is far stronger than the other
How to set a tolerance level for equality constraints
Why does '/' contain '..'?
Why is it called a stateful and a stateless firewall?
Wrong Schengen Visa exit stamp on my passport, who can I complain to?
Hobby function generators
Is my sink P-trap too low?
Delete empty subfolders, keep parent folder
Why does dd not make working bootable USB sticks for Microsoft?
Wouldn't Kreacher have been able to escape even without following an order?
Is it acceptable to use decoupling capacitor ground pad as ground for oscilloscope probe?
How to install Rasbian Stretch on Raspberry Pi 4?
ScrollTop inside css scrollbar (overflow-y: auto)
$(window).scrollTop() vs. $(document).scrollTop()Get text selected and update himJquery readmore function not working correctlyHow can I put <br> tag in <td> contents with JQuery?How to get only text from html tagFind and wrap SPAN around all selected words in a DIVAdd class to iframe inner body when parent body hasclassHighlighting a text from string by using sub-string methodGet the startoffset and endoffset of a string from a stringHow to capitalize all the chars of string after . like mobile keyboard
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am working on this accordion. Here, you can see list of accordion inside a scrollbar. Here, whenever we click on heading, it should scroll to top so that heading and text is visible properly. I have tried many things but it is not working inside scrollbar. Although code is perfectly outside where we don't have scrollbar. Here is the fiddle I have created. Hope anyone help.
https://jsfiddle.net/t2fpeq0d/
$('.accordion-block-heading').on('click', function()
var $this = $(this);
var $parent = $this.parent();
var $position = $this.position().top;
console.log($position);
$this.next().stop().slideToggle();
$('.site-accordion').animate(
scrollTop: $this.offset().top
, 2000);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
HTML-
<!-- Site Accordion -->
<ol class="site-accordion mt-30">
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block`enter code here`">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block" id="test">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block last-block" style="padding-bottom: 0">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
</ol>
<!-- Site Accordion -->
jquery scrolltop
add a comment
|
I am working on this accordion. Here, you can see list of accordion inside a scrollbar. Here, whenever we click on heading, it should scroll to top so that heading and text is visible properly. I have tried many things but it is not working inside scrollbar. Although code is perfectly outside where we don't have scrollbar. Here is the fiddle I have created. Hope anyone help.
https://jsfiddle.net/t2fpeq0d/
$('.accordion-block-heading').on('click', function()
var $this = $(this);
var $parent = $this.parent();
var $position = $this.position().top;
console.log($position);
$this.next().stop().slideToggle();
$('.site-accordion').animate(
scrollTop: $this.offset().top
, 2000);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
HTML-
<!-- Site Accordion -->
<ol class="site-accordion mt-30">
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block`enter code here`">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block" id="test">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block last-block" style="padding-bottom: 0">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
</ol>
<!-- Site Accordion -->
jquery scrolltop
add a comment
|
I am working on this accordion. Here, you can see list of accordion inside a scrollbar. Here, whenever we click on heading, it should scroll to top so that heading and text is visible properly. I have tried many things but it is not working inside scrollbar. Although code is perfectly outside where we don't have scrollbar. Here is the fiddle I have created. Hope anyone help.
https://jsfiddle.net/t2fpeq0d/
$('.accordion-block-heading').on('click', function()
var $this = $(this);
var $parent = $this.parent();
var $position = $this.position().top;
console.log($position);
$this.next().stop().slideToggle();
$('.site-accordion').animate(
scrollTop: $this.offset().top
, 2000);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
HTML-
<!-- Site Accordion -->
<ol class="site-accordion mt-30">
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block`enter code here`">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block" id="test">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block last-block" style="padding-bottom: 0">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
</ol>
<!-- Site Accordion -->
jquery scrolltop
I am working on this accordion. Here, you can see list of accordion inside a scrollbar. Here, whenever we click on heading, it should scroll to top so that heading and text is visible properly. I have tried many things but it is not working inside scrollbar. Although code is perfectly outside where we don't have scrollbar. Here is the fiddle I have created. Hope anyone help.
https://jsfiddle.net/t2fpeq0d/
$('.accordion-block-heading').on('click', function()
var $this = $(this);
var $parent = $this.parent();
var $position = $this.position().top;
console.log($position);
$this.next().stop().slideToggle();
$('.site-accordion').animate(
scrollTop: $this.offset().top
, 2000);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
HTML-
<!-- Site Accordion -->
<ol class="site-accordion mt-30">
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block`enter code here`">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block" id="test">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block last-block" style="padding-bottom: 0">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
</ol>
<!-- Site Accordion -->
$('.accordion-block-heading').on('click', function()
var $this = $(this);
var $parent = $this.parent();
var $position = $this.position().top;
console.log($position);
$this.next().stop().slideToggle();
$('.site-accordion').animate(
scrollTop: $this.offset().top
, 2000);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
HTML-
<!-- Site Accordion -->
<ol class="site-accordion mt-30">
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block`enter code here`">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block" id="test">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block last-block" style="padding-bottom: 0">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
</ol>
<!-- Site Accordion -->
$('.accordion-block-heading').on('click', function()
var $this = $(this);
var $parent = $this.parent();
var $position = $this.position().top;
console.log($position);
$this.next().stop().slideToggle();
$('.site-accordion').animate(
scrollTop: $this.offset().top
, 2000);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
HTML-
<!-- Site Accordion -->
<ol class="site-accordion mt-30">
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block`enter code here`">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block" id="test">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
<!-- Accordion Block -->
<li class="accordion-block last-block" style="padding-bottom: 0">
<h3 class="accordion-block-heading">Title question goes here lorem ipsum dolor?</h3>
<p class="accordion-block-content">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</li>
<!-- Accordion Block -->
</ol>
<!-- Site Accordion -->
jquery scrolltop
jquery scrolltop
edited Mar 28 at 12:52
Pete
43.7k20 gold badges81 silver badges125 bronze badges
43.7k20 gold badges81 silver badges125 bronze badges
asked Mar 28 at 12:45
Nishant SharmaNishant Sharma
351 silver badge6 bronze badges
351 silver badge6 bronze badges
add a comment
|
add a comment
|
2 Answers
2
active
oldest
votes
You can use Position, like this:
$("body, html").animate(
scrollTop: $("#accordian-block-1").position().top
);
Obviously, you need to add a unique id to each element.
I would recommend using .attr() to get the ID of whatever heading is clicked, and then parse the heading ID into a number. You can then use this number to supply the ID of the desired element/accordian block to scroll to.
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
add a comment
|
You are trying to position the site-accordion
element to top of the clicked accordion. You should be positioning the document body to the accordion element like this :
$([document.documentElement, document.body]).animate(
scrollTop: $position
, 2000);
Check this updated JS Fiddle
Pardon me for any spell errors, replying from my mobile device.
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
Hi Nishant, where exactly have you added your CSS? I'm unable to see any CSS in the fiddle present in your question? Did you create a new fiddle? If yes, can you please provide the link of it?
– user3613129
Mar 29 at 5:02
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55397994%2fscrolltop-inside-css-scrollbar-overflow-y-auto%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use Position, like this:
$("body, html").animate(
scrollTop: $("#accordian-block-1").position().top
);
Obviously, you need to add a unique id to each element.
I would recommend using .attr() to get the ID of whatever heading is clicked, and then parse the heading ID into a number. You can then use this number to supply the ID of the desired element/accordian block to scroll to.
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
add a comment
|
You can use Position, like this:
$("body, html").animate(
scrollTop: $("#accordian-block-1").position().top
);
Obviously, you need to add a unique id to each element.
I would recommend using .attr() to get the ID of whatever heading is clicked, and then parse the heading ID into a number. You can then use this number to supply the ID of the desired element/accordian block to scroll to.
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
add a comment
|
You can use Position, like this:
$("body, html").animate(
scrollTop: $("#accordian-block-1").position().top
);
Obviously, you need to add a unique id to each element.
I would recommend using .attr() to get the ID of whatever heading is clicked, and then parse the heading ID into a number. You can then use this number to supply the ID of the desired element/accordian block to scroll to.
You can use Position, like this:
$("body, html").animate(
scrollTop: $("#accordian-block-1").position().top
);
Obviously, you need to add a unique id to each element.
I would recommend using .attr() to get the ID of whatever heading is clicked, and then parse the heading ID into a number. You can then use this number to supply the ID of the desired element/accordian block to scroll to.
answered Mar 28 at 13:01
XanderXander
6571 gold badge6 silver badges19 bronze badges
6571 gold badge6 silver badges19 bronze badges
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
add a comment
|
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
add a comment
|
You are trying to position the site-accordion
element to top of the clicked accordion. You should be positioning the document body to the accordion element like this :
$([document.documentElement, document.body]).animate(
scrollTop: $position
, 2000);
Check this updated JS Fiddle
Pardon me for any spell errors, replying from my mobile device.
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
Hi Nishant, where exactly have you added your CSS? I'm unable to see any CSS in the fiddle present in your question? Did you create a new fiddle? If yes, can you please provide the link of it?
– user3613129
Mar 29 at 5:02
add a comment
|
You are trying to position the site-accordion
element to top of the clicked accordion. You should be positioning the document body to the accordion element like this :
$([document.documentElement, document.body]).animate(
scrollTop: $position
, 2000);
Check this updated JS Fiddle
Pardon me for any spell errors, replying from my mobile device.
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
Hi Nishant, where exactly have you added your CSS? I'm unable to see any CSS in the fiddle present in your question? Did you create a new fiddle? If yes, can you please provide the link of it?
– user3613129
Mar 29 at 5:02
add a comment
|
You are trying to position the site-accordion
element to top of the clicked accordion. You should be positioning the document body to the accordion element like this :
$([document.documentElement, document.body]).animate(
scrollTop: $position
, 2000);
Check this updated JS Fiddle
Pardon me for any spell errors, replying from my mobile device.
You are trying to position the site-accordion
element to top of the clicked accordion. You should be positioning the document body to the accordion element like this :
$([document.documentElement, document.body]).animate(
scrollTop: $position
, 2000);
Check this updated JS Fiddle
Pardon me for any spell errors, replying from my mobile device.
answered Mar 28 at 13:11
user3613129user3613129
3664 silver badges9 bronze badges
3664 silver badges9 bronze badges
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
Hi Nishant, where exactly have you added your CSS? I'm unable to see any CSS in the fiddle present in your question? Did you create a new fiddle? If yes, can you please provide the link of it?
– user3613129
Mar 29 at 5:02
add a comment
|
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
Hi Nishant, where exactly have you added your CSS? I'm unable to see any CSS in the fiddle present in your question? Did you create a new fiddle? If yes, can you please provide the link of it?
– user3613129
Mar 29 at 5:02
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
Please check again. My CSS was not updated there. Because of that there was no scrollbar. Now I have added it and you see, it is not working.
– Nishant Sharma
Mar 28 at 16:04
Hi Nishant, where exactly have you added your CSS? I'm unable to see any CSS in the fiddle present in your question? Did you create a new fiddle? If yes, can you please provide the link of it?
– user3613129
Mar 29 at 5:02
Hi Nishant, where exactly have you added your CSS? I'm unable to see any CSS in the fiddle present in your question? Did you create a new fiddle? If yes, can you please provide the link of it?
– user3613129
Mar 29 at 5:02
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55397994%2fscrolltop-inside-css-scrollbar-overflow-y-auto%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown