滚动屏幕显示
$(window).scroll(function() {
if ($(window).scrollTop() > 100) {
$(".goTop").fadeIn();
} else {
$(".goTop").fadeOut();
}
});
点击滚动屏幕到头部
$(".goTop").click(function() {
$('body,html').animate({ scrollTop: 0 }, 500);
return false;
});
获得文档点击坐标
$('.map area').click(function(e){
var e = e||window.event;
var top = e.clientY;
var left = e.clientX;
});
相对于屏幕
function getMousePos(event) { var e = event || window.event; return {'x':e.screenX,'y':screenY} }
相对浏览器窗口
function getMousePos(event) { var e = event || window.event; return {'x':e.clientX,'y':clientY} }
相对文档
function getMousePos(event) { var e = event || window.event; var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; var scrollY = document.documentElement.scrollTop || document.body.scrollTop; var x = e.pageX || e.clientX + scrollX; var y = e.pageY || e.clientY + scrollY; //alert('x: ' + x + '\ny: ' + y); return { 'x': x, 'y': y }; }
var fd_height=$('#fd').height(); //获取底高
var body_height=$(document).height(); //获取文栏高
var scroll=$(window).scrollTop(); //获取屏幕滚动
var win=$(window).height(); //获取屏幕高