javascript - how to show div on under button on onclick event -
from code have 3 button ,now cliked ** reply button 1** means want show 1 textarea bottom of button( reply button 1).else have select reply button 2 means want show textarea under reply button 2..i don't know how do.i new developer please me one
<div class="comment"> <div class="img-thumbnail"> <img class="avatar" alt="" src="../tv/dist/img/user2-160x160.jpg"> </div> <div class="comment-block"> <div class="comment-arrow"></div> <span class="comment-by"> <strong>kani</strong> <span class="pull-right"> <a href="javascript:void(0)" rel="<?php echo $com['id']//1?>" class="reply-btn"><i class="fa fa-reply"></i> reply button 1</a> </span> </span> <p>lorem ipsum dolor sit amet,</p> <span class="date pull-right">19-apr-2016 </span> </div> </div> <div class="comment"> <div class="img-thumbnail"> <img class="avatar" alt="" src="../tv/dist/img/user2-160x160.jpg"> </div> <div class="comment-block"> <div class="comment-arrow"></div> <span class="comment-by"> <strong>kani</strong> <span class="pull-right"> <a href="javascript:void(0)" rel="<?php echo $com['id']//2?>" class="reply-btn"><i class="fa fa-reply"></i> reply button 2</a> </span> </span> <p>lorem ipsum dolor sit amet,</p> <span class="date pull-right">19-apr-2016 </span> </div> </div> <div class="comment"> <div class="img-thumbnail"> <img class="avatar" alt="" src="../tv/dist/img/user2-160x160.jpg"> </div> <div class="comment-block"> <div class="comment-arrow"></div> <span class="comment-by"> <strong>kani</strong> <span class="pull-right"> <a href="javascript:void(0)" rel="<?php echo $com['id']//3?>" class="reply-btn"><i class="fa fa-reply"></i> reply button 3</a> </span> </span> <p>lorem ipsum dolor sit amet,</p> <span class="date pull-right">19-apr-2016 </span> </div> </div>
after click button want show
<textarea class="the-new-com"></textarea>
now should surely. need not use seperate ids each
js
$('.reply-btn').on('click',function() { $(this).closest('.comment').next('.reply').html("<div><textarea class='the-new-com'></textarea></div>"); })
html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="comment"> <div class="img-thumbnail"> <img class="avatar" alt="" src="../tv/dist/img/user2-160x160.jpg"> </div> <div class="comment-block"> <div class="comment-arrow"></div> <span class="comment-by"> <strong>kani</strong> <span class="pull-right"> <a href="javascript:void(0)" rel="<?php echo $com['id']//1?>" id="reply-btn-1" class="reply-btn"><i class="fa fa-reply"></i> reply button 1</a> </span> </span> <p>lorem ipsum dolor sit amet,</p> <span class="date pull-right">19-apr-2016 </span> </div> </div> <div class="reply"></div> <div class="comment"> <div class="img-thumbnail"> <img class="avatar" alt="" src="../tv/dist/img/user2-160x160.jpg"> </div> <div class="comment-block"> <div class="comment-arrow"></div> <span class="comment-by"> <strong>kani</strong> <span class="pull-right"> <a href="javascript:void(0)" rel="<?php echo $com['id']//2?>"id="reply-btn-2" class="reply-btn"><i class="fa fa-reply"></i> reply button 2</a> </span> </span> <p>lorem ipsum dolor sit amet,</p> <span class="date pull-right">19-apr-2016 </span> </div> </div> <div class="reply"></div> <div class="comment"> <div class="img-thumbnail"> <img class="avatar" alt="" src="../tv/dist/img/user2-160x160.jpg"> </div> <div class="comment-block"> <div class="comment-arrow"></div> <span class="comment-by"> <strong>kani</strong> <span class="pull-right"> <a href="javascript:void(0)" rel="<?php echo $com['id']//3?>" id="reply-btn-3" class="reply-btn"><i class="fa fa-reply"></i> reply button 3</a> </span> </span> <p>lorem ipsum dolor sit amet,</p> <span class="date pull-right">19-apr-2016 </span> </div> </div> <div class="reply"></div>
Comments
Post a Comment