Skip to content

Instantly share code, notes, and snippets.

@neilgee
Last active May 20, 2021 22:31
Show Gist options
  • Save neilgee/b79282395ad900ac16670480737c940c to your computer and use it in GitHub Desktop.
Save neilgee/b79282395ad900ac16670480737c940c to your computer and use it in GitHub Desktop.
Bricks Container Click
<script>
(function ($) {
$(function () {
clickContainer();
});
/*
* Make a whole Bricks Container clickable.
* There must be a link tag nested in the container element.
* Add the CSS class .click-container in the Container Settings CSS class value
* @link https://wpbeaches.com/make-a-whole-container-a-clickable-link-in-bricks-builder/
*/
function clickContainer() {
$('.click-container').css('cursor', 'pointer');
$('.click-container').on('click', function (event) {
$(this).find('a')[0].click();
});
$('.click-container a').on('click', function (event) {
event.stopPropagation();
});
}
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment