kleinmeyl
February 2, 2012
5:50am
I have added a test jquery file to my site through custom java script library.
I don't think it is loaded, how can I activate a custom jquery ?
// JavaScript Document
(function ($) {
$(document).ready(function() {$("p").css("border","solid 3px red");
}
})(jQuery);
Comments
4:56pm
Hi kleinmeyl,
Drupal 7 doesn't let you use $ as a shortcut for jQuery, unless you wrap your code like this:
function($){ // your code here }(jQuery);That creates an anonymous function inside of which $ equals jQuery, then immediately executes it.
If that's a bit too messy for you, then you can just use the jQuery variable in your functions, or you can assign var $ = jQuery; inside any function where you want to use the shortcut.
Hope that helps!
Best regards,
Stacy Wray | Drupal Gardens Client Advisor
3:23am
What you suggest, is what I did, but it does not work:
function($){
$(document).ready(function() {$("p").css("border","solid 3px red");
}(jQuery);
This is a test function for me, to see if the jquery works...
I also do not see in the head that it is loaded. It's called jquery.txt and I assigned it to the head.
See a printscreen of the code here http://isabeldesmet.be/Schermafbeelding2012-02-09.jpg