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();">
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();">
Share
Improve this question
asked Mar 30, 2014 at 22:54
Tarsem SinghTarsem Singh
211 gold badge1 silver badge7 bronze badges
5
- have you linked jquery before document.ready ? – karthikr Commented Mar 30, 2014 at 22:56
- Have you checked for errors in the browser console? – Pointy Commented Mar 30, 2014 at 22:56
- yes I have linked jquery before the document.ready. No errors or warnings in the browser console too. – Tarsem Singh Commented Mar 30, 2014 at 22:57
-
The
language
tag has been deprecated - I don't think this will affect execution, but best to remove it anyway. – Simon Robb Commented Mar 30, 2014 at 23:04 - @SimonRobb I was going to write not working but now it is working I don't know why, but it just worked. (But Not by removing 'language' tag). Thanks to all. – Tarsem Singh Commented Mar 30, 2014 at 23:14
2 Answers
Reset to default 2you 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.
you say "All required libraries", are you including several libraries ?
If this is the case, it could be possible that they are creating a conflict with jquery "$".
here is a webpage explaining this : https://api.jquery./jQuery.noConflict/
a test you can do, is going to your console entry in your browser's debugguer and try typing $('div'), or $('p'). If any of the html tags you select are recognize it means the $ is working, otherwise not.