0

I initiate clipboard.js:

        new Clipboard('#copy', {
            container: document.getElementById('.product-modal')
        });

However I have 2 inputs in the modal window. First one is being selected on load. When I need to copy second one I need to manually select text and click copy. How to solve the problem so when clicked copy button text is automatically copied from the right input?

Anyone?

miojamo
  • 723
  • 2
  • 14
  • 31

1 Answers1

0

Sorted:

        jQuery(document).ready(function () {
        new Clipboard('#copy', {
            target: function(trigger) {
                return trigger.previousElementSibling;
            }
        });
    });
miojamo
  • 723
  • 2
  • 14
  • 31