首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

jquery滚动护持定位层

2012-11-23 
jquery滚动保持定位层本插件借鉴了一些网上的资料,实际运用可以自行修改。/*! * jQuery scrollsPosition pl

jquery滚动保持定位层

本插件借鉴了一些网上的资料,实际运用可以自行修改。

/*! * jQuery scrollsPosition plugin * jquery滚动保持定位层 * Copyright (c) 2012 Geetaku *  * @author JSCZXY2 *  */$.fn.scrollsPosition = function() {var position = function(element) {element.css("z-index","999");var top = element.position().top, pos = element.css("position");$(window).scroll(function() {var scrolls = $(this).scrollTop();if (scrolls > top) {if (window.XMLHttpRequest) {element.css({position: "fixed",top: 0});} else {element.css({top: scrolls});}}else {if(pos == "relative"){element.css({position: pos,});}else{element.css({position: pos,top: top});}}});};return $(this).each(function() {position($(this)); });};

热点排行