This function call
$('#mydiv').paintRed();
paints the background of the DOM element with id mydiv red, if you’re using this code:
$.fn.paintRed = function() {
$(this).css("background-color", "red");
}
Well, okay. But now I want to ‘group’ my own functions. Now I want the programmer to use this function call to achieve the same as above:
$('#mydiv').subsub.paintRed();
How do I achieve that?
(Or else, if above request is not possible, is there any other way?)
Return an Object that has
paintRedas its property. By using this method all your functions can be “grouped” into thesubsubfunction.Fiddle