https://jsfiddle.net/jpbdk62m/ <html>
<head>
<style>
textarea {
width: 100%;
height: 200px;
}
</style>
</head>
<body>
<div class="postContent" id="post-15">
Formda kullandığımız gibi yazılan bir yazıyı alıntılamak işleminin mantığı nedir nasıl yapılır?
</div>
<textarea></textarea>
<button onClick="quote(15)">alıntı yap</button>
<button>gönder</button>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>
function quote(id) {
var textarea = $('textarea');
var textareaVal = textarea.val();
var post = $("#post-" + id);
var datas = $.trim(post.text()) + '\n';
textarea.val(function(i, text) {
return datas + text;
});
}
</script>
</body>
</html>js Jquery kütüphanesi ile şu şekilde bir mantıkla yazdım. 15 php'de döneceğiniz post id oluyor. geliştirebilirsiniz