Right now i'm currently using a simple bootstrap tooltip when I create my tables with jQuery, but i wanted a specific functionality that the bootstrap tooltip doesn't offer.
I want to be able to copy the base text and get something like "base text - hover text"; because i need both values when i paste it into excel, simply creating two columns for this data makes the table slightly too big, so i'm looking for another solution.
<a href="#" data-toggle="tooltip" title="hover text">base text</a>
$(document).ready(function(){
$("#query").click(function() {
$.ajax({
method: "GET",
url: $('#dns').val()
})
.done(function(data) {
if (data.Success == true) {
//this is where my table with the tooltips are created
parseResults(data.Results);
} else {
$('.dnsError').show();
}
$('[data-toggle="tooltip"]').on('copy', function(event) {
event.preventDefault();
console.log(this.title);
copyToClipboard(this.innerText + " - " + this.getAttribute('data-original-title'));
}).tooltip();
})
});
});
function copyToClipboard(text) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val(text).select();
document.execCommand("copy");
$temp.remove();
}