How to change class of separate div when hovering over link using JQuery

adrian collins

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 &amp; The Environment</a>

<script>
$("#hselink").mouseover(function(){
  $("#hse").addClass("boxshadow").removeClass("noshadow")
})
</script>

imvain2

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.

edited at
0

Comments

0 comments
Login to comment

Related

How to change css of one class when hovering over another?

Is there a way to change a target div's text when hovering over other div's using css only?

How to show div when hovering dynamically a link?

Change the Brightness of a div when hovering over another div

How do add a class to another div, when hovering over one div?

Change CSS of li class when hovering over a class

How do I change the class of several tds when hovering over one of them?

Change color of icon when hovering over div in which it is contained

Getting 2 divs to change colour when hovering over 1 div

Change class of other div when hovering on one div

Change Color of Icon When Hovering Over Adjacent Text With jQuery

How to get EpicGame's navbar transitions when hovering over link?

How to highlight a whole cell when hovering over link

How do I remove the space when hovering over a nav link?

How to set an image as a cursor when hovering over a link

how to change the visibility/opacity of another html element by hovering over another html element using jquery?

How to display a div when hovering over another div

How can I change a sites background image when hovering over a button using css?

How do you change a style of a child when hovering over a parent using material-ui jss styles

How to display a div when hovering over an image using CSS/HTML + Transitions?

How do I trigger a click when hovering over a element for x seconds, using JQuery?

How to change color of element when hovering over another element?

How to change the style of other elements when hovering over one of them?

How to change a plot when hovering over elements in Shiny?

how to make color change to white when hovering over button

How to change menu image when hovering over different links?

How to change font family + background when hovering over each letter

How to change color when hovering over a button in Tkinter?

How to change the color of the SVG when hovering over the image?