To copy a value to the clipboard, i use this function:
$(function() {
$('.copy-to-clipboard input').click(function() {
$(this).focus();
$(this).select();
document.execCommand('copy');
$(".copied").text("Link copied to clipboard").show().fadeOut(1200);
});
});
<div class='copied'></div>
<div class="copy-to-clipboard">
<input type="text" value="Text to grab" />
</div>
how can i achieve the same with the value in betweeen span
tags like below:
<div class="copy-to-clipboard">
<span>Text to grab</span>
</div>