Skip to content
Advertisement

JQuery not updating the background-image of a element?

When I hover over a picture on this page, I should be updating the larger div element’s src attribute above to be the image url of the image I am currently hovering over.

My breakpoints reach up to the

“$(‘#image’).on(‘hover’, function() {“

line, but won’t actually set the url attribute of the div element on the next line. Any pointers?

JavaScript
JavaScript

Advertisement

Answer

  1. Remove all inline event handlers
  2. Add mouseenter and leave handlers
  3. Access the css property

Divs do not have URLs

Also I moved the preview to not have to scroll too far down

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement