张家港人才网——www.zjgrc.com(function ($) {

\(.fn.floatAd = function (options) { var defaults = { speed: 10 //漂浮速度 单位毫秒 }; var options = \).extend(defaults, options); var obj = $(this); obj.css(‘position’, ‘fixed’);

function init() { var x = 0, y = 0, xin = true, yin = true;

$(window).mousemove(function(e){ var winX = e.clientX; var winY = e.clientY;

if(!yin) return;

x = winX-obj.offset().left; y = winY-obj.offset().top-50;

if(x<=0){ xin = false; y += parseInt(options.speed);}else if(x>=$(window).width()){ xin = false; y -= parseInt(options.speed);}

if(y<=0){ yin = false; x += parseInt(options.speed);}else if(y>$(window).height()-obj.outerHeight()){ yin = false; x -= parseInt(options.speed);}

obj.css(“left”,x+“px”); obj.css(“top”,y+“px”);

}) init(); } init(); });}(jQuery));