Scenario : Say using JQuery, i am listening to events on a webpage under class page > adminSwitch and page > premiumSwitch.
And whats new to me is, till this point i did’nt know with jQuery you can do something like this, say when we use $(this), it means we are refering to the element that triggered the event. In that triggered function, we can use $(this) to refer to the element. What i didn’t know is, we can call another function and don’t have to pass $(this) to it as jQuery does this automatically and refer the element that triggered the event.
This is the function getSwitchValues is defined before the above two statements. Notice the highlighted statement $(this) here refers to the toggle switch which triggered the event.