Trigger Lightbox opening in the DOM by ID

  contact-form-7, dom, javascript, lightbox

Sorry for my lack of knowledge and if this question appears too easy or dumb.

I use Flatsome theme with Woocommerce. Flatsome allows using shortcodes to create lightboxes.
I’ve created one and placed it in the footer. I want to use javascript to trigger opening this lightbox once a certain even happens. In my case once WPCF7 form is being submitted.

I’ve tried many different ways and all failed. One of them is the current code below.

Please, advise.

FOOTER SCRIPTS

[lightbox id="newsletter-submission" width="600px" padding="20px"]
  [block id="newsletter-submission"]
[/lightbox]

<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
  document.getElementById("newsletter-submission").open();
}, false );
</script>

Source: Ask Javascript Questions

LEAVE A COMMENT