Home > Web Front-end > JS Tutorial > body text

Summary of methods for js visual distance

零到壹度
Release: 2018-03-24 14:50:05
Original
1803 people have browsed it


This time I will summarize the knowledge points about js visual distance. The following is the specific content. Let’s follow the editor to take a look.

JQuery monitoring page scrolling summary

1. The distance from the top of the window where the current scroll is to the top of the entire page:

  var winPos = $(window).scrollTop();
Copy after login

2. Get the page position of the specified element:

    $(val).offset().top;
Copy after login

3. Monitor the rolling of the page scroll bar: place it when the page is loading

 $(window).scroll(function(event)});
Copy after login

4. Set the scroll bar to the specified position.

$(window).scrollTop(offset)。
Copy after login

##5,jQuery('#item'). The actual size of outerHeight()

#item, that is, height+padding+border

##6, jQuery('#item').outerHeight(true)
#The actual size and margin of the item, that is, height+padding+border+margin

Related recommendations:

The problem of calculating the visual distance height in JS

[Front-end] Summary of methods to determine whether an element is within the visible range

js gets the width and height of the visual area and body

The above is the detailed content of Summary of methods for js visual distance. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template