我有以下使用 zClip 允许复制到剪贴板的 jQuery。它只适用于一个选择器,但不适用于多个选择器。我正在尝试使用 $(this) 来选择父级,但它会使浏览器崩溃。
$('.copylink').zclip({
path:'ZeroClipboard.swf',
copy: jQuery(this).parent().text()
});
这是 zClip网站上给出的示例
$('a#copy-description').zclip({
path:'js/ZeroClipboard.swf',
copy:$('p#description').text()
});
// The link with ID "copy-description" will copy
// the text of the paragraph with ID "description"
我的 HTML
我正在尝试使用,需要选择上述html的父元素文本
<ul>
<li>the text i will like to select and pull <a href="" class="copylink">Copy</a></li>
<li>the text i will like to select and pull <a href="" class="copylink">Copy</a></li>
<li>the text i will like to select and pull <a href="" class="copylink">Copy</a></li>
<li>the text i will like to select and pull <a href="" class="copylink">Copy</a></li>
<li>the text i will like to select and pull <a href="" class="copylink">Copy</a></li>
</ul>
我相信我的问题在于在 javascript 对象中包含 jQuery 并使用它来捕获外部范围值。