<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(".btn2").click(function(){ $(this).closest(".first").hide(); }); }); </script> </head> <body> <div class = 'first' style="background-color:red;width:100px"><br> <div class = 'first' style="background-color:green;width:50px"><br> <button class = 'btn2'>.</button> </div> </div> <br /> <div class = 'first' style="background-color:blue;width:50px"><br> <button class = 'btn1'>..</button> </div> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more