"expand on click"
Bootstrap 4.1.1 Snippet by Reason706

<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 id="expand" class="row"> <a href="javascript:void(0)" id="comment-reply">click here</a> </div> <div id="nested" class="row m-2 " style="display:none;" > <h2>This is hidden</h2> </div> </div> <div class="container"> <div id="expand" class="row"> <a href="javascript:void(0)" id="comment-reply">click here</a> </div> <div id="nested" class="row m-2 " style="display:none;" > <h2>This is hidden</h2> </div> </div>
.active{ color:red; }
$(function() { $("a#comment-reply").click(function() { // remove classes from all $("div#nested").closest("active"); /* $("a").closest("div").css({ "color": "green", "border": "2px solid green" }); */ /* $("a").closest("div").siblings("#nested").css({ "color": "red", "border": "2px solid green" }); */ /* $(this).closest("div").siblings("#nested").css({ "color": "red", "border": "2px solid green" }); */ $("a#comment-reply").closest("div").siblings("#nested").fadeOut(); $(this).closest("div").siblings("#nested").fadeIn(); // add class to the one we clicked // $("a#comment-reply").fadeOut(); }); });

Related: See More


Questions / Comments: