0

I have a div: <div id="navUserDetailsNotifications"> and another div: <div id="navNotifications">. The initial state is that the first div is displayed (display: flex) and the second one is not (display: none). I want to attach "navUserDetailsNotifications" div 2 event listeners:

  • When click on it, then the second one is displayed (display: flex).
  • When click on document and the clicked element is not navUserDetailsNotifications then make display: none to the second div.

This is my try:

let navUserDetailsNotificationsOBJ = $('#navUserDetailsNotifications');
let navNotificationsOBJ = $('#navNotifications');

$(document).on('click', ':not(#navUserDetailsNotifications)', function() {
        navNotificationsOBJ.css('display', 'none');
});

navUserDetailsNotificationsOBJ.on('click', function() {
        navNotificationsOBJ.css('display', 'flex');
});

This is not working, why is it?

J HAED
  • 21
  • 3

0 Answers0