我想在单击Edit1时将第1段的内容复制到textarea中,当我单击Edit2时,也会复制第2段的内容

时间:2016-06-21 23:07:06

标签: function jquery-selectors

/*This is my jquery I am working with now*/

$(document).ready(function () {
    $('.edit').click(function() {
        var content = $('.paste').html();
        $('#area').html(content);
    });
});
<!--This is my html code am using.. I want when I click Edit 1 the content of paragraph one is copied into my textarea and when I click Edit 2 link the paragraph is copied into textarea. The code now is working such that when I click Edit 2 the content of Edit 1 is copied in both cases...-->
<div class="article">
    <p class="paste">Paragraph one </p>
    <a href="#" class="edit">Edit 1</a>
</div>
<div class="article">
    <p class="paste">Paragraph two </p>
    <a href="#" class="edit">Edit 2</a>
</div>
<textarea rows="5" class="form-control" placeholder="Enter text..." id="area"></textarea>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

1 个答案:

答案 0 :(得分:0)

I       1       A       OWNER
II      2       C       DRIVER
III     3       D       OWNER
IV      4       E       OWNER

我已经设法在线深入研究,并回答了我的问题。感谢愿意帮助我解答的任何人。