I need to change the class of the #hse div when hovering over a link, and revert back to the default class on mouseout. The link has been assigned the id "#hselink". I placed the script below into the WP header, but it is not working. (The site is not available to view.)
I have tried searching here, using scripts provided, and the div does not change.
<a href="#" id="hselink">Health, Safety & The Environment</a>
<script>
$("#hselink").mouseover(function(){
$("#hse").addClass("boxshadow").removeClass("noshadow")
})
</script>
You can simplify your process by having the no shadow style be the default style of the div then simply toggling the class of boxshadow
.
<script>
jQuery(document).ready(function(){
jQuery(document).on("mouseover", "#hselink", function(){
jQuery("#hse").toggleClass("boxshadow");
});
});
</script>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments