Jquery.on() Does Not Work In Wordpress Admin Panel
I'm writing my own WordPress(4.1.4) plugin which uses some JavaScript code in admin panel. The first issue is $ object is undefined, so I use jQuery instead. Now, I want to handle
Solution 1:
Make sure you code is running at the end of the document by running <?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>
, then setting the $in_footer
argument to true. Then the on
function should work as expected. I've tested in WP version 4.2.1, but it should still work in your 4.1.4 environment. This code will also allow you to use the $
.
(function($){
$(".my-button").on("click", function(e){
e.preventDefault();
alert("OK");
});
}(jQuery));
Post a Comment for "Jquery.on() Does Not Work In Wordpress Admin Panel"