Coding jQuery safely in WordPress

If you find this free website useful – why don’t you support this with a donation? It is easy…. read more ….

I keep forgetting the syntax so this is just to remind me.

In WordPress you want to ensure you don’t get conflicts with jQuery so there is a safe way to code it

jQuery(function( $ ) {
  // Your code using failsafe $ alias here...
});

And if you want it when the DOM is loaded then you can do it like this

jQuery( document ).ready(function($) {
    //  your code referencing $ here
});

 


Posted

in

, , ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *