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.
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