jQuery script in plugin doesnt work – "$ is not a function"
-
hi, I developed plugin with a lightbox script(using colorbox). there are two parts of code, one on the header to import the jQuery directory, the .js file and the .css file, and also a simple jQuery script.
the other part sould be somewhere in the <body> tag, so i put it on the footer.
here is the codes i have used:function head_code(){ echo "<link rel='stylesheet' href='https://reuven.karasik.org/plugins/files/lightbox/colorbox.css' />"; wp_enqueue_script( 'lbscript', 'https://reuven.karasik.org/plugins/files/lightbox/jquery.colorbox.js' ); wp_enqueue_script( 'lbjquerysciprt', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' ); $code = "<script>jQuery(document).ready(function(){jQuery('.inline').colorbox({inline:true, width:'50%'});jQuery('.inline').click();});</script>"; echo $code; }; add_action('wp_head', 'head_code');
and for the other part:
function foot_code() { echo "<p style='display: none;'><a class='inline' id='reuven' href='#inline_content'>Inline HTML</a></p><div style='display:none'><div id='inline_content' style='padding:10px; background:#fff;'><h1>".get_option('lightbox_content_ytm')."</h1></div></div>"; } add_action('wp_footer', 'foot_code');
if the way i put those codes is wrong, please tell me and give me example of right using.
anyway, the jQuery scripts arnt working, not when i write $(…) and not when i write jQuery(…).
the error says that there is no function “$”, witch means that the compiler thinks that i didnt import the jQuery directory, witch i did. beside that, there are other j|Query script from my theme, that work perfectly, and when i put the same code in a html file without wordpress it works. do you have any idea why the import of the jquery directory isnt working?
- The topic ‘jQuery script in plugin doesnt work – "$ is not a function"’ is closed to new replies.