How to invoke a method of js object after invoking another method?

Posted by Unitpage on Stack Overflow See other posts from Stack Overflow or by Unitpage
Published on 2010-04-02T16:43:54Z Indexed on 2010/04/02 17:13 UTC
Read the original article Hit count: 151

Filed under:
|
|

I often saw this code in jQuery.

$('div').action1().delay(miliseconds).action2();

I could realize it in one level action in the following code.

function $(id) {
   var $ =  document.getElementById(id);

   $.action1 = function() {

   };

  return $;

}

How to write the method delay() and action2() so that I could use them this way?

$('div').action1().delay(miliseconds).action2();

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about method