jquery窗口震动特效
;(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);
$(document).ready(function(){
$('.block').click(function(){
$(this).jshaker();
});
});
BODY{font-family: "Lucida Grande", Arial, Helvetica, sans-serif;color: #666666;font-size: 12px;background: #FFFFFF;}
A{color: #0A8ECC;}
A: HOVER{text-decoration: none;color: #8FCB2F;}
H1{font-weight: normal;color: #0A8ECC;margin: 0;padding: 0;}
BODY{margin: 20px;padding: 20px;}
STRONG{color: #000000;}
.vspacer{height: 20px;}
PRE.code{padding: 7px;background: #777777;color: #F0F0F0;width: 400px;overflow: auto;}
#content-area{border: 3px solid #CCCCCC;background: #F0F0F0;padding: 10px;width: 500px;}
P.script-link{clear: both;padding: 10px 0;border-top: 1px dotted #CCCCCC;}
#content .block {float: left;border: 1px solid #CCCCCC;background: #F0F0F0;padding: 10px;margin: 10px;width: 300px;}
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
Text Field 1:
Text Field 2:
Submit