• LValfre

    (@lvalfre)


    Currently I have this JQuery document in my theme’s JS folder to allow me to hover over images and swap them to the featured image like so:

    https://test.pillarsoflifebook.com/tables/tabletops/wood/rustic-plank-oak/rustic-plank-oak/

    function myFunction() {
        var $large = jQuery('#largeImage');
    
        //store the default image as the data src
        $large.data('src', $large.attr('src'));
    
        var src = jQuery('#largeImage').attr('src');
        jQuery('#thumbs img').hover(function () {
            $large.attr('src', jQuery(this).attr('src').replace('thumb', 'large'));
        }, function () {
            //on mouse leave put back the original value
            $large.attr('src', $large.data('src'));
        });
    }
    
    jQuery(document).ready(function () {
        jQuery(myFunction);
    });

    For another page in my clients site I need the same function WITHOUT the featured image returning to the original. Hence .. when you hover and the featured image changes … it needs to remain changed when you hover off again.

    Should I add another script (pretty much the same with minor adjustments) for this?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Did you have any luck figuring this out? I am looking to do something similar.

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else’s topic.

    I am now closing this 3 month old topic as it references an older version of WordPress.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘JQuery for Image Swap On Hover – Need Simple Adjustment’ is closed to new replies.