7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jQuery独自メソッドスニペット

Posted at

任意の値(param)とコールバック関数(fn)を引数とする、MyNewMethod という独自メソッドを追加。

$.fn.MyNewMethod = function(param, fn) {
    return $(this).animate({
        'height' : 0,
        'opacity': 0
    }, param, function() {
        $.isFunction(fn) && fn.call(this);
    });
};

var box = $('div');
$('button').on('click', function() {
    box.MyNewMethod(400, function() {
        console.log('callback');
    });
});
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?