I'm using Clipboard.js and am trying to get the text in a <td>
node using the following:
$('.clipboard').click(function(evt) {
clipboard.copy(evt.target.val()).then(
function(){console.log("success");},
function(err){console.log("failure", err);}
);
});
Obviously .val()
is not a valid method on evt.target
. What's the correct way of getting the nodes text value using evt
here?
evt.target.innerText
This will give you text value and innerHtml will give you entire content
It should be
$(evt.target).text()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With