Javascript Image Rollover
Hi I have a question about image rollover but it's not how you'd think. I've seen an example http://www.asos.com/ and click the home button(top nav far left) You can see that when
Solution 1:
First of all: Firebug is your friend. The technique employed is simpler than one might think: They just reduce the images' opacity to 0.3. As the background is black, the images appear darkened. So the code might look something like this:
$('img.fade').live('mouseover', function (e) {
var $this = $(this).fadeTo(500, 1.0);
$('img.fade').not($this).fadeTo(500, .3);
);
$('img.fade').live('mouseout', function (e) {
var $this = $(this);
$('img.fade').not($this).fadeTo(500, 1.0);
);
Solution 2:
Fast solution (it can be tuned shorter i guess):
<divclass="images"><imgsrc="http://www.google.com/google.jpg" /><imgsrc="http://www.google.com/google.jpg" /><imgsrc="http://www.google.com/google.jpg" /><imgsrc="http://www.google.com/google.jpg" /></div><scripttype="text/javascript">
$().ready(function(){
$('.images img').hover(
function(){
$(this).parents('.images').find('img').not(this).animate({"opacity": "0.3"}, 200);
$(this).animate({"opacity": "1"}, 200);
},
function(){
$(this).animate({"opacity": "1"}, 200);
}
);
$('.images').bind('mouseleave',function(){$(this).find('img').animate({"opacity": "1"}, 200);});
});
Post a Comment for "Javascript Image Rollover"