复制文本到剪贴板的功能。
从另一个元素中复制内容。你可以通过增加一个 data-clipboard-target
属性在您的触发元素中。
您在这个属性中包含的值需要匹配另一个元素选择器。
请按按钮并复制我!
<p id="copytext">Please press the button and copy me!</p> <button class="btn btn-white" data-clipboard-target="#copytext"><i class="fa fa-copy"></i> Copy</button>
此外,您可以定义 data-clipboard-action
属性来指定是否要 复制
或者 剪切
内容.
<textarea id="cuttext">This is example text that will be cuted fromt this textarea control.</textarea> <button class="btn btn-white" data-clipboard-action="cut" data-clipboard-target="#cuttext"><i class="fa fa-cut"></i> Cut to clipboard</button>