Click ID change section background image Elementor

				
					<script>window.addEventListener('DOMContentLoaded', function() {
jQuery(document).ready(function($) {
    // Define an object with tab IDs and corresponding image URLs
    const backgrounds = {
        '#moj1': 'https://www.demo.carbonweb.co/wp-content/uploads/2024/11/card-graphic.svg',
        '#moj2': 'https://www.demo.carbonweb.co/wp-content/uploads/2024/10/Frame-1261162052-2.png',
        '#moj3': 'https://www.demo.carbonweb.co/wp-content/uploads/2024/09/Frame-1261162340.png',
        '#moj4': 'https://www.demo.carbonweb.co/wp-content/uploads/2024/09/section-1.svg'
    };

    // Attach a click event to each tab
    $.each(backgrounds, function(tabId, imageUrl) {
        $(tabId).on('click', function() {
            // Change the background image of the section with ID #arif_wrap
            $('#moj_wrap').css('background-image', url(${imageUrl}));
        });
    });
});
});</script>
				
			

Leave a Reply

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

Latest tutorials

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