JQuery selectors not working in console

I cannot have my life working on this. I have js running and "container status ..." is the console log from running js on the page. It displays a selector, but if I want to do something in the console, it just returns null. I guess somehow I'm writing a jQuery function somewhere, as if I called jQuery

>>> $
function()

This is how I call the selector

Container state 3 jQuery(div.module-carousel)
>>> $('body')
null  
+5
source share
4 answers

jQuery uses 2 namespaces, jQueryand $. Another library might use $. Try using jQueryinstead $(assuming it is not overridden too):

jQuery('body');

jQuery $ , $ :

(function($){
    //"$" in here is jQuery
    //code that uses $ as jQuery will work in here
}(jQuery)); //pass in jQuery and execute
+6

, .

$ = jQuery.noConflict();
+4

$ ( jQuery), , :

$ = jQuery;

.

( , ) @Joseph the Dreamer.

+2

Firefox Chrome $ document.getElementById . , $.

, jQuery ( , ), jQuery.

If you do not need jQuery specific selectors, you can also use $$which is a shorthand for document.querySelectorAllwhich supports CSS selectors (3).

+1
source

All Articles