The first semi-colon ;
sets the following code apart from any other preceding code that may have forgot the semi-colon. This is important as the parens will try to run the previous statements as a function if the semi colon was not found.
For the rest of the code, we are just declaring an "in-line" function which will be immediately executed where the arguments $, window, document
are then instantiated as jQuery, this, this.document
(respectively) from the global scope. This is primarily so that you can use "$" within your new jQuery plugin without worrying if $
has been overwritten somewhere else. You can be sure that $
is the same as jQuery
.
Read more about "Protecting the $ Alias and Adding Scope" here
Update from OP:
For the if
statement returning false, be sure that your html is loaded at the time of calling your if
statement. One quick way to do this, is to wrap it in a $(document).ready
method like so:
$(document).ready(function () {
if($('ul.mtree').length) {
alert("got 'em!");
}
});