$('.cart6 .mini-gallery .img').click(function(){ var index = $(this).index(); var imageUrl =" ../images/es4-big"+(index+1)+".jpg"; $('.big-img').css('background-image', 'url(' + imageUrl + ')'); }); 

When clicking on a picture, it changed to a large one from the images folder. When transferring to WordPress, the links stopped working. How to fix?

    1 answer 1

     var imageUrl ="/директория_от_корня_сайта/images/es4-big"+(index+1)+".jpg"; 
    • True, but even better is to use get_stylesheet_directory_uri() - KAGG Design
    • This is js and not php. And js in a separate file, as a rule. - Andrew ProjectSoft
    • I understand that perfectly. But if not in a separate file, but formed within php (which is crooked, but often found), then it’s better through the function WP - KAGG Design
    • That's exactly what if in the body of the page, then this is already obtained through the op. Therefore, in no case do not offer options with php for js questions. Especially for CMS. - Andrew ProjectSoft
    • OK OK))) ...... - KAGG Design