diff --git a/index.html b/index.html index a882158..6e5e2ef 100644 --- a/index.html +++ b/index.html @@ -130,6 +130,26 @@ allowtransparency="true" frameborder="0" scrolling="0" width="156" height="30">< Copy to clipboard </button> +
If you don't want to modify your HTML, there's a pretty handy imperative API for you to use. All you need to do is declare a function, do your thing, and return a value.
+ +For instance, if you want to dynamically set a target
, you'll need to return a Node.
new Clipboard('.btn', {
+ target: function(trigger) {
+ return trigger.nextElementSibling;
+ }
+});
+
+ If you want to dynamically set a text
, you'll return a String.
new Clipboard('.btn', {
+ text: function(trigger) {
+ return trigger.getAttribute('aria-label');
+ }
+});
+
There are cases where you'd like to show some user feedback or capture what has been selected after a copy/cut operation.