"Check .hasClass after check your class addClass"
Bootstrap 4.1.1 Snippet by sumi9xm

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <h4>on click href="a" or different class and ID Check .hasClass after check your class addClass with if else</h4> </div> </div>
$(document).ready(function () { $('a').click(function () { if ($('.right-sidebar-warp').hasClass('sidebar-shwo')) { $('.add-overlay').addClass("overlay"); } else { $('.add-overlay').removeClass("overlay"); } }); }); $(document).ready(function () { $('#questCreat, #manageQuests, #OnOneOn, #user-profile, #nation_setting').click(function () { if ($('.right-sidebar-warp').hasClass('sidebar-shwo')) { $('.add-overlay').addClass("overlay"); } else { $('.add-overlay').removeClass("overlay"); } }); });

Related: See More


Questions / Comments: