1

I am using popper js to show a pop up in my website. I want to close the popup when I click anywhere in window.

here is what I have tried:

var popp = $('#popp');
popp.hide();

$('#filters li i ').click(function () {
    var ref = $(this).val();

    $(this).toggleClass('text-danger')
    popp.toggle()

    var popper = new Popper(ref, popp, {
        placement: 'right',
    });
});
ryryan
  • 3,890
  • 13
  • 43
  • 72

1 Answers1

1

What I did was to create a method that recieves a click, then check if this click happened inside the button, if it was he will show the tooltip, other wise he doesn't.

function tooltipClick(click){
  document.addEventListener(click, function(event) {
    let isClickInside = button.contains(event.target);

    if (isClickInside) {
      show();
    }
    else{
      hide();
    }
  });

}
Jean Paiva
  • 11
  • 2