function waitForSwiperInstance(selector, callback, timeout = 5000) {
const start = Date.now();
const interval = setInterval(() => {
const el = document.querySelector(selector);
if (!el) return;
const swiper = el.swiper || (window.jQuery && jQuery(el).data('swiper'));
if (swiper) {
clearInterval(interval);
callback(swiper);
}
if (Date.now() - start > timeout) {
clearInterval(interval);
}
}, 100);
}
document.addEventListener('DOMContentLoaded', function () {
waitForSwiperInstance('#my-carousel .elementor-image-carousel-wrapper', function (swiperInstance) {
// Handle clicks on dynamic images
document.querySelectorAll('.jet-listing-dynamic-image__link').forEach(link => {
link.addEventListener('click', function () {
const img = this.querySelector('img');
const altText = img?.getAttribute('alt')?.trim()?.toLowerCase();
if (!altText) return;
const slides = swiperInstance.slides;
let matchedIndex = -1;
slides.forEach((slide, index) => {
if (slide.classList.contains('swiper-slide-duplicate')) return;
const caption = slide.querySelector('.elementor-image-carousel-caption');
const captionText = caption?.textContent?.trim()?.toLowerCase();
if (captionText === altText && matchedIndex === -1) {
matchedIndex = index;
}
});
if (matchedIndex !== -1) {
swiperInstance.slideTo(matchedIndex);
}
});
});
// Handle button with show-first-image
document.querySelectorAll('[show-first-image="true"]').forEach(button => {
button.addEventListener('click', function () {
swiperInstance.slideToLoop(0);
});
});
});
});
twat
Rubén Darío, Polanco, Polanco V Sección, Ciudad de México, CDMX
$200 /m²
($40,000)
Space Details
atast
Highlights
No data was found
Location
Contact Advertiser
Contact the advertiser for more information about this property.
Explore Similar Corporate Properties
jQuery(document).ready(function() {
jQuery('#go-back').on('click', function() {
window.history.go(-1);
return false;
});
});








