Background colour change on rollover
General Discussion
25
Posts
2
Posters
5.5k
Views
-
Hi Marius
Ok so far my code appears like this -
CUSTOM HEAD CONTENT:
<script> window.laytheme.on("newpage", function(layoutObj, type, obj){ jQuery(document).on("hover", ".thumb", function(event) { jQuery("body").removeClass("red"); jQuery("body").removeClass("blue"); var category = jQuery(this).attr("data-catid"); if (category == 1) { jQuery("body").addClass("red"); } if (category == 2) { jQuery("body").addClass("blue"); } } ); }); </script>and CSS
.red { background: #f1f1f1!important; } .red:hover { background-color: #ff1900 !important; } .blue { background: #f1f1f1 !important; } .blue:hover { background-color: #0280f8 !important; }but the hover only works when the mouse leaves the window not when leaving the thumbnail
Chers
Toby -
Dear @Toby
this works:
.red { background: red !important; } .blue { background: blue !important; }<script> window.laytheme.on("newpage", function(layoutObj, type, obj){ jQuery(document).on("mouseenter", ".thumb", function(event) { var category = jQuery(this).attr("data-catid"); if (category == 1) { jQuery("body").addClass("red"); } if (category == 2) { jQuery("body").addClass("blue"); } }); jQuery(document).on("mouseleave", ".thumb", function(event) { jQuery("body").removeClass("red"); jQuery("body").removeClass("blue"); }); }); </script>All the best!
Marius
-
Dear @Toby
this works:
.red { background: red !important; } .blue { background: blue !important; }<script> window.laytheme.on("newpage", function(layoutObj, type, obj){ jQuery(document).on("mouseenter", ".thumb", function(event) { var category = jQuery(this).attr("data-catid"); if (category == 1) { jQuery("body").addClass("red"); } if (category == 2) { jQuery("body").addClass("blue"); } }); jQuery(document).on("mouseleave", ".thumb", function(event) { jQuery("body").removeClass("red"); jQuery("body").removeClass("blue"); }); }); </script>All the best!
Marius
-
Perfect! Happy to hear!
Online Users
Forgot your key, lost your files, need a previous Lay Theme or Addon version?
Go to www.laykeymanager.com