Insights / Tutorial

Click Text to Change Image in Elementor

Letting visitors click a piece of text to swap an image makes your page interactive and engaging. In this tutorial you will build that effect in Elementor using a small amount of JavaScript.

LIVE PREVIEW / IMAGE-SWAP

Click the text to change the image.

The selected label controls which image is shown.

Architecture illustration

A live recreation of the technique explained in the guide below.

Letting visitors click a piece of text to swap an image makes your page interactive and engaging. In this tutorial you will build that effect in Elementor using a small amount of JavaScript. Copy the code, match the ids, and your images will change on click.

Initial Image Show/Hide CSS

  1. selector .all-img{
  2. display: none;
  3. }
  4. selector .img-1{
  5. display: block;
  6. }

Text Data Attribute

  1. data-showme|img-1

Dynamic Image Hide/Show JS

  1. <script src=“https://code.jquery.com/jquery-3.6.0.min.js”></script>
  2. <script>
  3. var $ = jQuery
  4. $(document).ready(function(){
  5. $(‘[data-showme]’).hover( function(){
  6. event.preventDefault();
  7. var showme = $(this).attr(‘data-showme’)
  8. $(‘.all-img’).hide()
  9. $(‘.’ + showme).show()
  10. })
  11. })
  12. </script>

How it works

Each clickable text item is linked to a target image by a shared id or data value. A short script listens for clicks on the text and updates which image is shown. Because the logic is simple, it runs instantly and works alongside the rest of your Elementor layout.

Tips and customization

  • Add as many text and image pairs as you need.
  • Highlight the active text item with a CSS class for clarity.
  • Add a fade transition so the image change feels smooth.

FAQ

Does this require a plugin?
No. A small custom script in an HTML widget is all you need.

Can I use it on mobile?
Yes. Clicks work as taps on touch devices.

ARTICLE END

Ready to make it work?

I can help turn the idea into a reliable WordPress experience.

Start a conversation ↗

Need help with this?

Let's build it for you

If this guide is close to what you need, I can build the complete solution on your WordPress site.

Prefer email? f@mojibur.com