Created
April 11, 2025 22:14
-
-
Save askwpgirl/36d2b7c8ea91a46685526f14ca344f63 to your computer and use it in GitHub Desktop.
Flipbox script for click custom flipbox in Elementor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function($) { | |
function setupFlipBoxes($scope) { | |
$scope.find('.custom-flip-box').each(function () { | |
const $flipBox = $(this); | |
$flipBox.off('click').on('click', function () { | |
$flipBox.toggleClass('flipped'); | |
}); | |
}); | |
} | |
// Run on initial load (frontend and editor) | |
$(document).ready(function () { | |
setupFlipBoxes($(document)); | |
}); | |
// Run again when Elementor renders widgets in the editor | |
$(window).on('elementor/frontend/init', function () { | |
elementorFrontend.hooks.addAction('frontend/element_ready/html.default', setupFlipBoxes); // use .default to apply to all HTML widgets | |
elementorFrontend.hooks.addAction('frontend/element_ready/container.default', setupFlipBoxes); // also useful for flex containers | |
}); | |
})(jQuery); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment