Reasons for invalid element scrolltop settings and Solutions

Source: Internet
Author: User

When doing a project, you need to set the scrolltop of a hidden element and then display it. The use of jquery scrolltop method, but ineffective, Baidu for a long time, still can not find an effective solution. So I created a new Web page to test the reasons for the failure of ScrollTop method, after a toss, finally understand the cause of the problem and solutions.

The cause of scrolltop failure

When an element's display property is ' None ', setting the ScrollTop property on the element is not valid, so even the jquery scrolltop method will not work.


Solutions

Setting the element to the visible state (el.style.display= ' block '), you can set the native El.scrolltop property or the ScrollTop method of jquery.


Experience: To go online to find a solution to the problem is not a panacea, more often still need to do their own step-by-step debugging, and then get a solution.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.