读书人

Jquery 小技能

发布时间: 2012-10-29 10:03:53 作者: rapoo

Jquery 小技巧
查找出对象为一段html时 查找this的子对象用children无效 要用find。



自定义属性的使用


屏幕中央显示元素
关键点在于documentElement。

var scrolled_height = document.documentElement.scrollTop; 会得出浏览器滚动条已卷上的高度, 故可准确定位于屏幕中央。

function clever_popup_show(popup){//request data for centeringvar windowWidth = document.documentElement.clientWidth;var windowHeight = document.documentElement.clientHeight;var scrolled_height = document.documentElement.scrollTop;var popupHeight = popup.height();var popupWidth = popup.width();//centeringpopup.css({    "top": windowHeight/2-popupHeight/2+scrolled_height,    "left": windowWidth/2-popupWidth/2}).show();$(".popup_shadow").css({height : $(document).height(),width : $(document).width()}).show();}

读书人网 >Web前端

热点推荐