This is called method chaining. It's possible if the method you're calling returns the object reference, and not if it isn't. (But you want to remove the , after the first call.)
So it would work with this, for instance:
function Thingy() {
}
Thingy.prototype.html = function(value) {
// ...do something with `value`...
// return `this` for chaining:
return this;
};
Thingy.prototype.css = function(name, value) {
// ...do something with `name` and `value`...
// return `this` for chaining:
return this;
};
var t = new Thingy();
t.html('test')
.css('color', 'green');
Most of jQuery's functions, for instance, return this for chaining purposes when used as setters (if you're using jQuery, as it seems you might be from the names of the functions you quoted). (When they're used as getters, of course, they return the value you're getting rather than this.)
But it won't work if the function doesn't return the object reference:
Thingy.prototype.html = function(value) {
// ...do something with `value`...
};
t.html('test')
.css('color', 'green'); // Fails, because what `html` returned wasn't an object