js让页面加载后向下滑动一段距离

JavaScript09

js让页面加载后向下滑动一段距离,第1张

页面加载完成事件JQuery是$(function() { 这是页面加载完成后会执行的代码})页面下滑代码$('html,body').animate({scrollTop:100px},500)100px为从顶部开始向下滑的距离 500为下滑时间 单位为毫秒 可以控制下滑速度时间越短下滑速度越快 两者结合 即可实现你说的页面加载后向下滑动一定距离

jQuery监听鼠标滚轮(滚动)事件

第一步:下载jquery-mousewheel插件

第二步:复制以下代码做测试,打开日志看效果

jQuery(function($) {

$('#nav')

.bind('mousewheel', function(event, delta) {

var dir = delta >0 ? 'Up' : 'Down'

if (dir == 'Up') {

console.log(“向上滚动, www.imiansha.com”)

} else {

console.log(“向下滚动, http: //blog.csdn.net/u011627980”)

}

return false

})

})

}