What does it mean?
The document.body
in javascript is a direct reference to the DOM element representing the <body>
portion of the page.
The $()
part depends on how it is used. $
could be a variable name, and ()
after a variable or property name attempts to call a function stored in that variable or property.
So if you have:
var $ = function() { alert('howdy'); };
Then this:
$();
...will call that function, and trigger the alert.
Functions can accept arguments, so you could modify the function above to accept the document.body
element as an argument, and alert()
its innerHTML
(for example);
// alerts the innerHTML of the element it receives
var $ = function( elem ) { alert( elem.innerHTML ); };
$( document.body ); // Passes the element when calling the $ function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With