Posts

Showing posts with the label div outside click jquery

How can I detect a click outside of an element?, In jQuery

Image
How can I detect a click outside of an element?, In jQuery Now coming to the main answer - “How can I detect a click outside of an element?, In jQuery”.  HTML  <button>click</button> <div class="clickinside"> <h1>Hello Test 123</h1> </div>  CSS  <style> .clickinside {     background: wheat;     height: 250px;     width: 250px;     padding-top: 10px;     box-sizing: border-box;     text-align: center;     display:none; } button {     margin-bottom: 20px;     background: #32b566;     border: none;     padding: 10px 20px;     font-size: 16px;     color: #fff;     border-radius: 3px; } </style>  JQUERY <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script...