In JavaScript
, you will often see functions which say document.getElementById("element").someFunction();
or $("element").someFunction();
instead of someFunction($("element"));
. Where someFunction(element)
looks a little like the following code.
someFunction(element) {
//element.doSomething();
}
My question is how do you make a function which manipulates the element it is attached to instead of manipulating an element passed through as an argument?