$("document").ready( function (){
    (".happy").clicked(function (){
        (".sad").html("Happy");
    });
});

How does javascript call jquery because am really confuse suppose I have the following code?

$("document").ready( function (){
    (".happy").clicked(function (){
        (".sad").html("Happy");
    });
});

is it because the function is an anonymous function so when the javascript gets loaded thing works because from a python to call a function I would give it a name then use parentheses
The leading $ is actually an alias for the jQuery function 🙂
This $("document").ready() is an event listener. Once the document (DOM) is ready, the function callback inside the .ready() method is called.
but what am confused about is that when you write the ready function as

 ready( function (){  
      (".happy").clicked(function (){
            (".sad").html("Happy");
        });
});

In the ready function we put the anonymous function inside, so is it that due to the function be anonymous so it does not require the ready function explicitly called is that why the function I have inside the first anonymous function gets triggered. for example inside the { } of the function that goes into the ready function. sorry I came from python.
Members
Online

source