有没有办法使用 jQuery 根据窗口滚动的距离来做不同的事情?
这是我现在使用的代码;
$(document).scroll(function() {
// If scroll distance is 500px or greated
if ( $(document).scrollTop() >= 500 ) {
// Do something
} else {
// Go back to normal
}
});
Run Code Online (Sandbox Code Playgroud)
我想做的是这样的事情;
$(document).scroll(function() {
// If scroll distance is 500px or greater
if ( $(document).scrollTop() >= 500 ) {
// Do something
// If scroll distance is 1000px or greater
} else if ( $(document).scrollTop() >= 1000 ) {
// Do something else
} else {
// …Run Code Online (Sandbox Code Playgroud) 是否可以使用 HTML 画布或 Javascript 单击图像的一部分,并根据您单击的部分触发 Javascript 事件?
所以,例如;
如果我有一个手表的图像并且用户点击表带,这会触发一个与表带相关的内容的模态。同样,如果他们点击其中一个表针,这会触发不同的模态。