javascript - jQuery: How does functions works just by dots (.) -
this question has reply here:
how can jquery method chaining? [duplicate] 7 answerssince learned jquery i've wondering how jquery execute function after adding dots .
(dont know real name, sorry that);
$("#somediv").fadein("fast").css("background","blue");
when fade effect finished css function execute. if can execute whatever function want 1 after another.
how can that?
note: if named wrong, please right me, want learn.
it returns same type of object, here's trivial illustration demonstrates technique:
var counter = function(){ this.val = 0; }; counter.prototype.increment = function(){ ++this.val; homecoming this; }; counter.prototype.decrement = function(){ --this.val; homecoming this; }; counter.prototype.log = function(){ console.log(this.val); homecoming this; }; var o = new counter(); o.increment().increment().decrement().log().increment().log();
javascript jquery
No comments:
Post a Comment