troubleshooting Question

Closing drop down tab by clicking outside.

Avatar of Adebayo Ojo
Adebayo OjoFlag for Nigeria asked on
7 Comments1 Solution267 ViewsLast Modified:
Please I need someone to help me with this. I've tried to fix it but not working as expected. I want to close a drop down tab by clicking both the tab button and outside the tab. I was able to open the drop down by clicking on the tab button and close it by clicking outside the tab, but I cannot close the tab by clicking on the tab button. Below are my codes:

<div id="notify" style="display:inline-block; cursor:pointer;">'.'<img id="note_still" src="images/note_still.png" width="31" height="30" alt="Notes">
<div id="notecontainer" class="notecontainer" style="display:none; border:solid 1px lightslategray; margin-top:2px;">';
<div id="notedisplay" class="notedisplay">'.$notify_result.'</div>';
<div id="spanBase" style="height:40px; width:300px; background-color:gray; text-align:center;"><a style="color:white; font-weight:800;" href="">View all notifications</a></div>

//**********Function for notification drop-down menu*******//

$(document).ready(function() {
    $("#notify").click(function() {
// Close the dropdown menu if the user clicks outside of it
window.addEventListener('mouseup', function(event) {
    var box = document.getElementById('notecontainer');
    if ( != box && != box) { = 'none';
//***************Ends Here*********************************//

I tried to add another jquery to hide the dropdown on clicking the tab icon(
img id="note_still" src="images/note_still.png"
but the dropdown refused to even open up when I applied the script.
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros