The Jquery is not working with wordpress . its throws $ is undefined .
Code :
$('.action').on("change",function(e){
// my code
})
The Jquery is not working with wordpress . its throws $ is undefined .
Code :
$('.action').on("change",function(e){
// my code
})
The Wordpress Already Have Inbuild Jquery method so .
Try This . The Function Change The All $
to jquery
and Working Fine .
(function($){ // use it as $
$(document).ready(function(){ // make sure DOM is ready
$('.action').on("change",function(e){ // bind the change event
// my code
});
});
})(jQuery); // pass jQuery in the IIFE
No Need To Add Jquery Library. As wordpress bundles with jQuery internally but uses jQuery
keyword instead of its alias $
.
Use
wp_enqueue_script(
'my_voter_script',
plugins_url( '/js/main.js' , __FILE__ ),
array( 'jquery' )
);
On Plugin Init Page To load External JS file
In Wordpress it includes the jquery. Try to replace all $
with jQuery
and check. May be after replace $
with jQuery
all working fine.