This plugin generates generic collection classes, that work almost exactly as jQuery does.
These collections include all those jQuery functions, that are used to manipulate the collection itself.
The included built-in functions are:
add, andSelf, attr, each, end, eq, extend, filter, get, implement, include, index, init, is, map, not, pushStack, setArray, size and slice.
Every collection will have a build() function, that will create a new collection class, that inherits from the caller. $.collection is a collection class by itself. So other collections will inherit from it, or its subclasses.
With this plugin, you can manipulate native data types like String or Array, with your custom methods, without actually modifying their prototype. This is shown in some of the examples below.
If you want additional information and more details about some of the methods.
Check this explanatory text, also included in the release.
Examples
$.collection(1,2,3,4).filter([2,3]).eq(1);//--> [ 3 ]
$.number = $.collection.build();
$.number.fn.sum = function(){
var n = 0;
this.each(function(){ n += this; });
return n;
};
$.number(1,2,3,4).add(5).not(function(){
return this <= 2;
}).sum();//yields --> 12 ( 3 + 4 + 5 )
$.array = $.collection.build();
$.array.fn.include( Array.prototype, 'join,push' );
var $arr = $.array('I','like','xyz','jQuery').add('very').not('xyz');
$arr.push( 'much' );
$arr.join(' ');// yields --> 'I like jQuery very much'
var Nodes = $.collection.build();
Nodes.fn.init = function( elems ){
elems = document.getElementsByTagName(elems);
return this.setArray( $.makeArray(elems) );
};
Nodes('body').add('script').attr('className','node');//-->[ <body>, <script>, <script> ]
var MyString = $.collection.build();
MyString.implement( String.prototype, 'replace,toUpperCase');
MyString('jQuery','Quack').replace('Q','X').toUpperCase()// --> [ 'JXUERY', 'XUACK' ]
Please, make sure to upgrade to 1.0.3
The plugin is very easy to master and is relatively small, less than 2KB packed
jQuery中$.each()与collection.each()中的function()函数 两者都是可以同遍历jQuery对象与非jQuery对象的方法,基本使用如下: var li = $("li"); li.each(function(index,element){ console.log(index); console.log($(this).text()); } );
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="../js/jquery-1.9.1.min.js"></script> </head> <style type="text/css"> div { c
jQuery Templates plugin vBeta1.0.0 jQuery Templates is no longer in active development, and has been superseded by JsRender. JsRender functionality is a superset of the jQuery Templates feature set, a
1 JQuery动画效果 1. 基本效果 show([s,[e],[fn]]) 显示隐藏的匹配元素 hide([s,[e],[fn]]) 隐藏显示的元素 toggle([s],[e],[fn]) 如果元素是可见的,切换为隐藏的;如果元素是隐藏的,切换为可见的 参数详解 speed : 三种预定速度之一的字符串("slow","normal", or "fast")或表示动画时长的毫秒数值(如
jQuery Panzoom是一款非常实用的HTML DOM元素平移和缩放jQuery和CSS3插件。Panzoom利用CSS transforms 和 matrix函数来为浏览器进行硬件(GPU)加速,它可以支持任何元素的平移和缩放:图片、视频、iframe、canvas或文本等等。 IE8及以下的浏览器不支持这个插件。 Mobile support Panzoom支持移动手机的触摸姿势,也支持