How to fix the a href tag clickable?

I have an html css code for notification dropdown box the issues is i can’t able to click the tag and same time i tried with javaScript also not working i can’t understand this issues please advice me how to make a clickable tag..

  $('.toparea-right > .setting-area > li').on("click",function(){
	$(this).siblings().children('div').removeClass('active');
	$(this).children('div').addClass('active');
	return false;
  });
    
//------- remove class active on body
  $("body *").not('.toparea-right > .setting-area > li').on("click", function() {
	$(".toparea-right > .setting-area > li > div").removeClass('active');
      return true;
 });
.dropdowns {
        background: #FFF none repeat scroll 0 0;
        border: 1px solid #e1e8ed;
        list-style: outside none none;
        max-height: 294px;
        overflow: auto;
        padding-left: 0;
        position: absolute;
        right: -175px;
        text-align: left;
        top: 55px;
        width: 440px;
        opacity: 0;
        visibility: hidden;
        -webkit-transition: all 0.3s linear 0s;
        -moz-transition: all 0.3s linear 0s;
        transition: all 0.3s linear 0s;
    }
    
    .dropdowns.active{
        opacity: 1;
        visibility: visible;
    }
    
    .drops-menu {
        list-style: outside none none;
        padding-left: 0;
    }
    
    .drops-menu > li > a {
        border-bottom: 1px solid #e1e8ed;
        display: inline-block;
        padding: 5px;
        width: 100%;
    }
    
    .dropdowns > h6{
        font-size: 15px;
    }
    
    .drops-menu > li > .tag {
        color: #fff;
        display: inline-block;
        font-size: 11px;
        padding: 0 6px;
        position: absolute;
        right: 0;
        top: 0;
    }
    
    .drops-menu > li:nth-child(2n) > a {
        background: whitesmoke none repeat scroll 0 0;
    }
    
    .drops-menu > li a img {
        display: inline-block;
        vertical-align: middle;
        width: 10%;
        border-radius: 100%;
        margin-bottom: 10px;
        margin-left: 10px;
        height: 45px;
    }
    
    .mesg-meta {
        display: inline-block;
        padding-left: 30px;
        vertical-align: middle;
        width: -1%;
        color: #000000;
        padding-top: -21px;
        top: 18px;
        margin-top: 0px;
        line-height: 25px;
    }
    
    .mesg-meta > h6 {
        font-size: 13.5px;
        font-weight: 600;
        letter-spacing: 0.3px;
        margin-bottom: 0;
        text-transform: capitalize;
        margin-left: -15px;
    }
    
    .mesg-meta > span {
        color: #000000;
        display: inline-block;
        font-size: 12px;
        line-height: 15px;
        overflow-x: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: 100%;
    }
    
    .mesg-meta > i {
        color: #000000;
        font-size: 12px;
        font-style: normal;
        margin-left: -15px;
    }

    .drops-menu > li > a:hover {
        background: #fafafa none repeat scroll 0 0;
    }
    
    .dropdowns > span {
        border-bottom: 1px solid #ccc;
        display: inline-block;
        font-size: 14px;
        padding: 0px 10px;
        text-align: center;
        width: 100%;
        height: 59px;
        margin-top: 0px;
    }
    
    .dropdowns > a.more-mesg {
        display: inline-block;
        font-size: 14px;
        padding-bottom: 5px;
        text-align: center;
        text-transform: capitalize;
        width: 100%;
    }
    
    .blue{background: #337ab7;}
    .red{background: #ff0000;}
    .green{background: #33b7a0;}
    .dropdowns.active > a {
        background: #fafafa none repeat scroll 0 0;
        display: block;
        font-size: 13px;
        margin-bottom: 2px;
        padding: 0px 0px;
        text-align: center;
    }
    
    .dropdowns.active > a i {
        font-size: 11px;
        left: 8px;
        position: absolute;
        top: 10px;
    }
    
    .dropdowns.languages {
        width: 100px;
    }
    
    .dropdowns.active > a:hover {
        background: #f1f1f1 none repeat scroll 0 0;
    }
<div class="toparea-right">
   <ul class="setting-area">
      <li>
         <a href="#"><i class="far fa-newspaper"></i></a>
         <span class="notifi-count" id="displayNotiCount">00</span>
         <a href="#" class="a-left">Notifications</a>
         <div class="dropdowns">
            <ul class="drops-menu">
               <li>
                  <a href="view-post.php" onclick="window.location.href('view-post.php')" title="">
                     <div class="mesg-meta-notification">
                        <h6>Bruce Wayne</h6>
                        <span>is commented in your post!</span>
                        <i>0 min ago</i>
                     </div>
                  </a>
               </li>
            </ul>
         </div>
      </li>
   </ul>
</div>

I attached my CSS and HTML code and i tried it’s working but URL is opening in another tab. i need open the url in same tab please tell me the solution how to fix this.

Answer

In your code dropdown isn’t ever made visible.

I think, you on click of “Notifications” you have to toggle(hide/show) dropdown by toggling(adding and removing) “active” class on <a href="#" class="a-left"> Notifications </a> tag.

Once your dropdown becomes visible. clicks should work as you desire.

Sample working code:

    <a href="#" class="a-left" onClick="toggleDropdownVisibility()">Notifications</a>
  <script>
    function toggleDropdownVisibility(event) {
      var notificationBell = event.target;
      if (notificationBell.classList.contains('active')) {
        notificationBell.classList.remove('active');
      } else {
        notificationBell.classList.add('active');
      }
    }
    </script>

In addition to that please remove onclick="window.location.href('view-post.php')" as window.location.href is not a function instead it a property to which a url can be assigned. like window.location.href='view-post.php' . But you can completely remove this onclick as its not needed.