Zclip on multiple inputs
I'm trying to implement zclip to copy input's content into clipboard. There is 20 text inputs on the page like this:
<input type="text" value="content to copy..." />
<input type="text" value="another content to copy..." />
And I came up with this jQuery code:
jQuery(function() {
jQuery("input[type=text]").click(function() {
var link = jQuery(this).val();
jQuery(this).zclip({
开发者_JAVA百科path: '/img/ZeroClipboard.swf',
copy: link
});
});
});
In the Javascript console I get this error: Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function.
How can I get this working? Thx
Seems as if you use jQuery in noConflict mode. ZClip assumes that this is not the case and tries to extend the '$'. I just replaced every '$' in the jquery.zclip.js with 'jQuery' and the error message disappeared. If there is another way to run zClip in noConflict mode let me know.
Use each
instead of click and use a function to return the link value
jQuery(function() {
jQuery("input[type=text]").each(function() {
var link = jQuery(this).val();
jQuery(this).zclip({
path: '/img/ZeroClipboard.swf',
copy: function(){return link;}
});
});
});
精彩评论