You cannot reference this.elements in the setMaincolor method. this -pointer refers to your object style: use O.elements.main() in your O.style.setMaincolor function.
style: { setMaincolor: function() { return (O.elements.main()); } }
Although, I do not recommend this approach, note that you can also use: O.style.setMaincolor.call(O,[]); which makes this O link.
Here is how I would solve it:
var O = (function() { var self = { elements: { main: function() { return jQuery("#main"); }, footer: function() { return jQuery("#footer"); } }, main: function(html) { return self.elements.main(); }, style: { setMaincolor: function() { return self.elements.main(); } } }; return self; }());
source share