Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="comment1">
- <p class="comment">Hello World</p>
- <button class="edit">edit</button>
- </div>
- <div id="comment2">
- <p class="comment">Hello World 123</p>
- <button class="edit">edit</button>
- </div>
- <div id="comment3">
- <p class="comment">Hello World 456</p>
- <button class="edit">edit</button>
- </div>
- <br>
- <textarea class="commentArea"></textarea>
- $('.edit').click(function(e){
- var target = $(e.target),
- prevComment = target.parent().children().filter('p.comment'),
- commentText = prevComment.text();
- $('.commentArea').text(commentText);
- });
Add Comment
Please, Sign In to add comment