I need help with modal

I can only display the modal on loading if I use jquery and the js excerpt below, does anyone know a way to display the modal without using jquery?

$(document).ready(function() {
  $('#cookies').modal('show');
});

Create a button and change the target selector to the modal

image

or if you want vanilla javascript:

var cookieModal = new bootstrap.Modal(document.getElementById('cookies'));
cookieModal.show();

2 Likes

Perfect thank you @richards

Hi @richards,

I’m kinda new to the whole web scene, so bear with me if I say something stupid.

My understanding of the OP is that he wants to display a modal “on loading”. If I understand your post correctly, you instruct him to use a button. I fear I don’t understand how this relates to “on loading”. Will using a button not require user interaction?

Can you elaborate? Thanks.

It was just giving the op two different options, one with a button and one with javascript.