Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
47
rated 0 times [  48] [ 1]  / answers: 1 / hits: 18011  / 10 Years ago, sun, march 30, 2014, 12:00:00

I am working for selecting the text from a text box to the clipboard with the help of zclip. But the document.ready() is not working. It is not even showing the alert.
All required libraries are above the script tag and inside the head section. All the files are at the required positions.



I have even checked the files along with the full URL.



<script type=text/javascript language=javascript>
$(document).ready(function(){
alert('hi');
$(a#copy_initiator).zclip({
alert('hi');
path:js/ZeroClipboard.swf,
copy:function(){return $(input#copy-box).val();}
});
});
</script>


<a id=copy_initiator>Copy Link:</a> <input id=copy-box type=text value=here_is_a_url onfocus=this.select();>

More From » jquery

 Answers
118

you have a syntax problem here:



    $(a#copy_initiator).zclip({
alert('hi');
path:js/ZeroClipboard.swf,
copy:function(){return $(input#copy-box).val();}
});


should be:



$(a#copy_initiator).zclip({
path:js/ZeroClipboard.swf,
copy:function(){
return $(input#copy-box).val();
}
});


And better version:



$(#copy_initiator).zclip({
path:js/ZeroClipboard.swf,
copy:function(){
return $(#copy-box).val();
}
});


Suggestion: use firebug to track these kind of issues.


[#71700] Friday, March 28, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lewis

Total Points: 739
Total Questions: 100
Total Answers: 94

Location: Nepal
Member since Mon, Jan 4, 2021
3 Years ago
;