PDA

View Full Version : js opactiy constant blink



KaranSokhey
12-23-2011, 09:15 PM
Hi all,

wondering if its possible to create a constant blink without hover:


function fade_hover() {
jQuery('.fade_hover').hover(
function() {
jQuery(this).stop().animate({opacity:0.4},400);
},
function() {
jQuery(this).stop().animate({opacity:1},400);
});

}

Any help is appreciated :eek:

jscheuer1
12-24-2011, 06:16 AM
<!DOCTYPE html>
<html>
<head>
<title>jQuey Blinking Opacity Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($){
var targetOpacities = [0.4, 1], opacityIndex = 0;
function fadeThem(){
$('.faders').animate({opacity: targetOpacities[opacityIndex]}, 400, fadeThem);
opacityIndex = opacityIndex? 0 : 1;
}
fadeThem();
});
</script>
</head>
<body>
<p><img class="faders" src="photo1.jpg" alt="original image" title=""></p>
<p><img class="faders" src="photo2.jpg" alt="original image" title=""></p>
</body>
</html>

Demo:

http://home.comcast.net/~jscheuer1/side/files/fade_blink_jq_h.htm

KaranSokhey
12-24-2011, 05:49 PM
Thank you my friend.

Happy Holidays! :)