script.aculo.us ScrollTo 效果
在本文中,我们将通过使用名为script.aculo.us的 JavaScript 库来演示ScrollTo的效果,该库具有从一个到另一个的平滑过渡。我们也可以调整效果的持续时间。
句法:
Effect.ScrollTo('element_id', { duration:'0.2', offset:-20 });
注意:要使用这个库,我们应该安装这个库,然后在我们的程序中使用它。为此,您可以点击此链接 http://script.aculo.us/downloads。
方法:为了演示这个函数的使用,我们编写了一小段代码。我们编写了一个名为ShowEffect()的小 JavaScript函数,它使用了这个库的Effect.ScrollTo()方法。通过点击点击我滚动! ,你会清楚地看到效果。
示例:要查看效果,首先下载库,然后在本地环境中打开该程序。
HTML
script.aculo.us Effect.ScrollTo
JavaScript is a lightweight, cross-platform
and interpreted scripting language.
It is well-known for the development of web
pages, many non-browser environments also
use it.
JavaScript can be used for
Client-side developments as well as
Server-side developments.
Features of JavaScript: According to
a recent survey conducted by Stack Overflow,
JavaScript is the most popular language
on earth.
With advances in browser
technology and JavaScript having moved into
the server
with Node.js and other
frameworks, JavaScript is capable of so much
more.
Here are a few things that we can
do with JavaScript:
JavaScript was created in the first place
for DOM manipulation.
Earlier websites
were mostly static, after JS was created
dynamic Web sites were made.
Functions
in JS are objects. They may have properties
and methods just like another object.
They can be passed as arguments in other
functions.
Can handle date and time.
Performs Form Validation although the forms are
created using HTML.
No compiler needed.
JavaScript is a lightweight, cross-platform and
interpreted scripting language.
It is well-known for the development of web pages,
many non-browser environments also use it.
JavaScript can be used for Client-side
developments as well as Server-side
developments.
Features of JavaScript: According
to a recent survey conducted by Stack
Overflow,
JavaScript is the most
popular language on earth.
With advances in browser technology and
JavaScript having moved into the server
with Node.js and other frameworks,
JavaScript is capable of so much more.
Here are a few things that we can do
with JavaScript:
JavaScript was created in the first place
for DOM manipulation.
Earlier websites
were mostly static, after JS was created
dynamic Web sites were made.
Functions in JS are objects. They may have
properties and methods just like another
object.
They can be passed as arguments
in other functions.
Can handle date
and time.
Performs Form Validation
although the forms are created using HTML.
No compiler needed.
JavaScript is a lightweight, cross-platform
and interpreted scripting language.
It is well-known for the development of
web pages, many non-browser environments
also use it.
JavaScript can be used
for Client-side developments as
well as Server-side developments.
Features of JavaScript: According to a
recent survey conducted by Stack Overflow,
JavaScript is the most popular language on
earth.
With advances in browser technology
and JavaScript having moved into the server
with Node.js and other frameworks,JavaScript is
capable of so much more.
Here are a few
things that we can do with JavaScript.
JavaScript was created in the first place for
DOM manipulation.
Earlier websites were
mostly static,after JS was created dynamic
Web sites were made.
Functions in JS are
objects. They may have properties and methods
just like another object.
They can be
passed as arguments in other functions.
Can handle date and time.
Performs Form Validation although the forms are
created using HTML.
No compiler needed.
JavaScript is a lightweight, cross-platform and
interpreted scripting language.
It is well-known for the development of web pages,
many non-browser environments also use it.
JavaScript can be used for Client-side developments
as well as Server-side developments.
Click me to scroll!
输出: