Home  >  Article  >  Web Front-end  >  Example of scrollLeft() method usage in jQuery_jquery

Example of scrollLeft() method usage in jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:19:551049browse

The example in this article describes the usage of the scrollLeft() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This method gets or sets the offset of the matching element relative to the left side of the scroll bar.

Grammar structure 1:

When the scrollLeft() method has no parameters, it gets the offset of the matching element relative to the left side of the scroll bar.

Copy code The code is as follows:
$(selector).scrollLeft()

Example code:

Copy code The code is as follows:






Script Home













Grammar structure 2:

When scrollLeft() takes parameters, it sets the offset of the matching element relative to the left side of the scroll bar.

Copy code The code is as follows:
$(selector).scrollLeft(val)

Parameter list:

参数 描述
val 设置水平滚动条左侧偏移量

Example code:

Copy code The code is as follows:






Script Home













I hope this article will be helpful to everyone’s jquery programming design.

This article is reproduced from: Ant Tribe http://www.softwhy.com/

Statement:
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