2019-06-172019-06-14(前端第十五节知识点(j

2019-06-17  本文已影响0人  彝_e37e

尺寸相关、滚动事件:

1、获取和设置元素的尺寸

width()、height()    获取元素width和height 

innerWidth()、innerHeight()  包括padding的width和height 

outerWidth()、outerHeight()  包括padding和border的width和height 

outerWidth(true)、outerHeight(true)  包括padding和border以及margin的width和height

2、获取元素相对页面的绝对位置

offset()

3、获取可视区高度

$(window).height();

4、获取页面高度

$(document).height();

5、获取页面滚动距离

$(document).scrollTop(); 

$(document).scrollLeft();

6、页面滚动事件

$(window).scroll(function(){ 

    ...... 

})


鼠标移入移出:

进入子元素也触发

$('#div1').mouseover(function() {

$(this).animate({marginTop: 50});//.stop()

});

$('#div1').mouseout(function() {

$(this).animate({marginTop: 100});//.stop()

});

进入子元素不触发*/

$('#div1').mouseenter(function() {

$(this).stop().animate({marginTop: 50});

});

$('#div1').mouseleave(function() {

$(this).stop().animate({marginTop: 100});

});

通过hover(mouseenter+mouseleave)实现简写

上一篇下一篇

猜你喜欢

热点阅读