Files
old-holivud2/app/assets/javascripts/clipboard.js

19 lines
474 B
JavaScript
Raw Normal View History

2020-05-31 22:38:19 +02:00
$(document).on("click", "[data-behavior=clipboard]", function(e) {
e.preventDefault();
// Copy the value of the link's `href` attribute
var value = $(this).attr("href");
// Creates a temporary input field to copy from
var copyToClipboard = function(value) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val(value).select();
document.execCommand("copy");
$temp.remove();
}
// Perform the copying
copyToClipboard(value);
});