WordPress jQuery Uncaught TypeError: The '$' property of the [object Object] is not a function
I convert my html files to a WordPress theme and I use the ZClip plugin to copy text to the clipboard. The ZClip plugin works fine in my html demo, but when converting to WordPress I got this strange syntax error "Uncaught TypeError: The" $ "property of the [object Object] is not a function" on line 288 in zclip.js which
$(this.domElement).data('zclipId', 'zclip-' + this.movieId); I think this is something with the $ not sure variable. I read something about how jQuery might run into each other in WP, so I changed the main.js file to
jQuery(document).ready(function($){ ... $("button").zclip({ path:'js/ZeroClipboard.swf', copy: function() { return $(this).attr("data-coupon"); } }); }); functions.php
<?php function load_styles_and_scripts(){ //load css wp_enqueue_style( 'main-styles', get_template_directory_uri().'/style.css' ); // load scripts wp_enqueue_script( 'jquery', 'http://code.jquery.com/jquery-1.10.1.min.js' ); wp_enqueue_script( 'zclip-script', get_template_directory_uri().'/js/zclip.js' ); wp_enqueue_script( 'main-script', get_template_directory_uri().'/js/main.js' ); } add_action('wp_enqueue_scripts', 'load_styles_and_scripts'); Finally realized this after a whole day, lol. It seems that WP 3.5.2 is loading an older version of jQuery 1.8.3 and I am using the new version and it is not loading due to this line
wp_enqueue_script( 'jquery', 'http://code.jquery.com/jquery-1.10.1.min.js' ); perhaps 'jquery' is reserved for a local installation of jquery WP I changed it and my site starts working, but according to the user, it is not recommended here.
wp_enqueue_script( 'jq', 'http://code.jquery.com/jquery-1.10.1.min.js' );