Click Text to Change Image in Elementor

Click text to change image using 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. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest tutorials

Elementor vs Bricks compared — performance, ease of use, design flexibility, ecosystem, and pricing —...
Build a smooth 3D flip card in Elementor with pure CSS — no plugin, no...
Add a glowing, moving gradient border to any Elementor container or button using pure CSS...
Freelancer Mojibur
freelancer mojibur

Start a Project!

Interested in working together? Send a quick message or schedule a meeting. Ask questions, discuss details, and decide if we are a good fit.

Website Project Inquiry

This form helps me get a general idea. We’ll schedule a meeting soon to discuss everything in more detail!

Freelancer Mojibur

Contact person

For quick communication email at: freelancermojibur@gmail.com