I am having hard time trying to make $ work with my javascript. This is the line of code I am using. If i use jQuery, it works as expected but if I use $, it says $ is not defined. Any advices?
if (typeof Drupal !== 'undefined') {
// Define Drupal behavior.
(function ($, Drupal) {
Drupal.behaviors.floatingButton = {
attach: function(context) {
$('body').css('background', 'red'); // $ is not defined
jQuery('body').css('background', 'red'); // works fine
},
};
})(jQuery, Drupal);
}
if
statement.