代码如下:    
 jquery窗口震动特效  script>  
;(function($){ 
var element = {}; 
$.fn.jshaker = function(){ 
element = $(this); 
element.css('position', 'relative'); 
element.find('*').each(function(i, el){ 
$(el).css('position', 'relative'); 
}); 
var iFunc = function(){ $.fn.jshaker.animate($(element)); }; 
setTimeout(iFunc, 50); 
}; 
$.fn.jshaker.animate = function(el){ 
$.fn.jshaker.shake(el); 
el.find('*').each(function(i, el){ 
$.fn.jshaker.shake(el); 
}); 
var iFunc = function(){ $.fn.jshaker.animate(el); }; 
setTimeout(iFunc, 50); 
} 
$.fn.jshaker.shake = function(el){ 
var pos = $(el).position(); 
if(Math.random() > 0.5){ 
$(el).css('top', pos['top'] + Math.random() * 20 < 10 ? (Math.random() * 20 * (-1)) : Math.random() * 20); 
} else { 
$(el).css('left', pos['left'] + Math.random() * 20 < 10 ? (Math.random() * 20 * (-1)) : Math.random() * 20); 
} 
} 
})(jQuery); 
 script>  
$(document).ready(function(){ 
$('.block').click(function(){ 
$(this).jshaker(); 
}); 
}); 
 script>     
jquery窗 口 震 动 特 效
   点击本框内,可实现震动
  Item 1 Item 2  
Item 3 
 
Sub Item 1 Sub Item 2 Sub Item 3 Sub Item 4 Sub Item 5   Item 4 Item 5        
     
下载本文