How to copy text from the block?

There is so much construction

<div class="main">
<span>DSP</span>
<a href="#" class="button">Order now</a>
</div>

<div class="main">
<span>MDF</span>
<a href="#" class="button">Order now</a>
</div>


How to make it so that after clicking copy a text block from where the click was made, not of all units (many of them).

$(".button").click(function(){
var text = $(".main span").text();
$(".zakaz").text(text);
});
June 26th 19 at 14:21
1 answer
June 26th 19 at 14:23
Solution
var text = $(this).parent().find('span').text();

Find more questions by tags jQuery