Ik heb en een stylesheet switcher. Als ik van style switch gebeurd dit door javascript. Ik wil verschillende hover effecten bij de verschillende layouts. Maar daar gaat het mis, jquery hover script ziet niet dat ik een div een andere class heb gegegeven en dus voert hij geen andere hover uit. Maar via een alert en een background-color verandering, check of deze wel gebeurt.
Het hoverScript wat ik nu toe pas werkt dus niet goed, want 'hasClass' werkt niet meer als ik de class name heb veranderd. Ik kan nergens in de documentatie van jquery of nieuwsgroepen iets vinden om dit anders aan te pakken.
Als je tussen layouts switched en dan refreshed zie je wel de andere hover effecten...
Hier een live demo:
http://edwinistrator.com/stuff/jquery-problem/
Het hoverScript wat ik nu toe pas werkt dus niet goed, want 'hasClass' werkt niet meer als ik de class name heb veranderd. Ik kan nergens in de documentatie van jquery of nieuwsgroepen iets vinden om dit anders aan te pakken.
Als je tussen layouts switched en dan refreshed zie je wel de andere hover effecten...
Hier een live demo:
http://edwinistrator.com/stuff/jquery-problem/
JavaScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| $(document).ready(function(){ if($("#content").hasClass("thumbs")){ $(".thumbs .content_block .overlay").css({"opacity": 0 }); $(".thumbs .content_block").click(function(){ window.location=$(this).find("a").attr("href");return false; }); $(".thumbs .content_block").hover(function(){ $(this).find(".overlay").css({'display' : 'block'}); $(this).find("img").stop().animate({ "opacity": .2 }, 300); $(this).find(".overlay").stop().animate({ "opacity": 1 }, 300); }, function() { $(this).find("img").stop().animate({ "opacity": 1 }, 300); $(this).find(".overlay").stop().animate({ "opacity": 0 }, 300); }); } else if($("#content").hasClass("small")) $(".small .content_block").click(function(){ window.location=$(this).find("a").attr("href");return false; }); $(".small .content_block").hover(function(){ $(this).find(".overlay").css({'display' : 'block'}); $(this).find("img").stop().animate({ "opacity": .8 }, 300); $(this).find(".overlay").stop().animate({ "opacity": 0.8 }, 300); }, function() { $(this).find("img").stop().animate({ "opacity": 1 }, 300); $(this).find(".overlay").stop().animate({ "opacity": 1 }, 300); }); } else if($("#content").hasClass("big")) $(".big .content_block").click(function(){ window.location=$(this).find("a").attr("href");return false; }); $(".big .content_block").hover(function(){ $(this).find(".overlay").css({'display' : 'block'}); $(this).find("img").stop().animate({ "opacity": .8 }, 300); $(this).find(".overlay").stop().animate({ "opacity": 0.8 }, 300); }, function() { $(this).find("img").stop().animate({ "opacity": 1 }, 300); $(this).find(".overlay").stop().animate({ "opacity": 1 }, 300); }); } }); |