Zeroclipboard - 复制和格式化文本
我正在努力创建一个选择集以传递到 Zeroclipboard 客户端,以基本格式化的形式复制各种 HTML 元素的内容。我可以直接从变量 var myTextToCopy = "Hi, this is the text to copy!";
将文本传递给客户端,但无法使 HTML 元素的文本内容起作用。
有人可以指出我哪里出错了吗?
<script src="_assets/js/ZeroClipboard.js" type="text/javascript"></script>
<script language="JavaScript">
var clip = new ZeroClipboard.Client();
var myTextToCopy = $(".sideInfo ul:first-child").text() + "\r\n" + $(".sideInfo ul:nth-child(2)").text() + "\r\n" + $(".sideInfo ul:nth-child(3)").text() + $('.description').text();
clip.setText( myTextToCopy );
clip.glue( 'copyme' );
</script>
<div id="copyme">Copy To Clipboard</div>
<div class="sideInfo">
<ul>
<li>Episode: x</li>
<li>Production house: x</li>
<li>Contacts: Tim nicebutdim<br><a href="mailto:[email protected]">[email protected]</a></li>
</ul>
</div>
<div class="description">
Text text texttext <br /> text text text</div>
I am struggling to create a selection set to pass through to a zeroclipboard client to copy the contents of the various HTML elemnts in a basically formatted form. I can pass through text to the client directly from the variable var myTextToCopy = "Hi, this is the text to copy!";
but cannot get the text content of HTML elements to work.
Can someone point out where I am going wrong?
<script src="_assets/js/ZeroClipboard.js" type="text/javascript"></script>
<script language="JavaScript">
var clip = new ZeroClipboard.Client();
var myTextToCopy = $(".sideInfo ul:first-child").text() + "\r\n" + $(".sideInfo ul:nth-child(2)").text() + "\r\n" + $(".sideInfo ul:nth-child(3)").text() + $('.description').text();
clip.setText( myTextToCopy );
clip.glue( 'copyme' );
</script>
<div id="copyme">Copy To Clipboard</div>
<div class="sideInfo">
<ul>
<li>Episode: x</li>
<li>Production house: x</li>
<li>Contacts: Tim nicebutdim<br><a href="mailto:[email protected]">[email protected]</a></li>
</ul>
</div>
<div class="description">
Text text texttext <br /> text text text</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
而不是
使用
然后尝试使用
最后将其添加到您的代码中
Instead of
use
Then try to use
Finally add this around your code