Possible Duplicate:
How does basic object/function chaining work in javascript?
Is there a way to make native function chainable?
For example, I want to do this:
var ele = document
.createElement("div")
.setAttribute("id", "foo")
.focus();
instead of this:
var ele = document.createElement("div");
ele.setAttribute("id", "foo");
ele.focus();
Is there a way to do that? If it is possible, then it will definitely save me a lot of typing works.