Skip to content

mistakster/jquery-noop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

The smallest jQuery plugin ever

Описание плагина по-русски

Overview

The simplest and smallest plugin will only consist of a single expression return this.

$.fn.noop = function () {
	return this;
};

Utility of this plugin is not obvious at first glance. If you call it as usual, the result will be the same unmodified collection of items.

$("div.title").noop().doSomething();

The practical benefit of it will be when the plug-in should be called implicitly.

$("div.title")[isVisible() ? "fadeTo" : "noop"](333, 0).doSomething();

In some cases this notation is useful when you don't need to save the results of query in a variable. In a particular example is fairly natural chaining of several actions on items.

Note

This plugin was inspired by Artyom Polikarpov's tweet.

License

This plugin is licensed under a Creative Commons Attribution 3.0 Unported License.

About

The smallest plugin ever

Resources

Stars

Watchers

Forks

Packages

No packages published