Skip to content

Instantly share code, notes, and snippets.

@askwpgirl
Created April 11, 2025 22:14
Show Gist options
  • Save askwpgirl/36d2b7c8ea91a46685526f14ca344f63 to your computer and use it in GitHub Desktop.
Save askwpgirl/36d2b7c8ea91a46685526f14ca344f63 to your computer and use it in GitHub Desktop.
Flipbox script for click custom flipbox in Elementor
<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