Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #638324

    is there a way to show two different images, for example, a thumbnail image and then show a different image when the thumbnail is clicked? We have a situation where we need to show the FRONT and BACK of something.

    #638408

    Hey vegaspro,

    You can do that on mouse hover using css sprites. Please check https://css-tricks.com/spriting-img/ and https://css-tricks.com/css-sprites/

    You can change :hover to :active to make it work similar to onclick :)

    To do it the jQuery way Please try adding this at the very end of your themes / child themes functions.php file:

    function swap_img(){
    ?>
    <script>
    jQuery(document).load(function(){	
    // Add your jQuery script here
    jQuery("img").on('click', function () {
       jQuery(this).attr("src","new.gif")
    })
    
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'swap_img');

    Let us know if you have any questions.

    Best regards,
    Vinay

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.