How to use the $ jquery in wordpress?

Asked

Viewed 101 times

1

wordpress indicates using the following code:

( function( $ ) {
    // Your code goes here
} )( jQuery );

But I am using the zurb Foundation 6, and I believe this will not be enough to run it along with the wordpress Jquery, since the Foundation itself has several calls using $ inside it.

How can I get $calls passed to Jquery Wordpress automatically?

  • Have you tried using the noConflict() jQuery? For example, to change the simple $ of jQuery to another, put in the code, for example, var $a = jQuery.noConflict();... so jQuery’s commendations became $a instead of just $.

2 answers

0

jQuery(document).ready(function($) {
  // Pode usar normalmente aqui dentro.
  $('#element').hide(); //exemplo
});

Another way would be just assigning the variable $:

$ = jQuery;

After this line could use normally. The first option is safer to be used in Wordpress.

0


wordpress does this for security, not to happen load other libraries that use the $ and that are not jQuery.

If you’re sure that doesn’t happen, and the library you need to use really has the $ declared, so all you have to do is window.$ = jQuery; after the script where you load jQuery in wordpress, ie before loading that library you need.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.