Background colour change on rollover
-
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
-
Thank You Marius - Thats Great!
-
Perfect! Happy to hear!
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it
Online Users
Forgot your key, lost your files, need a previous Lay Theme or Addon version?
Go to www.laykeymanager.com