-
You can now request an element's entire data object by passing no arguments to
data()(Note: jQuery >=1.4 does this anyway):$(element).data(); // => {/* data object */} -
The
bindmethod accepts multiple events handlers by passing an object with each property as a handler (Note: jQuery >=1.4 does this anyway):$(element).bind({ click: function(){}, mouseover: function(){}, mouseout: function(){} }); -
The
bindmethod also accepts a non-function event handler in the form of an actionable-object:$(element).bind('click', { toggleClass: 'something' }); // This applies to one(), click(), mouseover() etc. etc. -
There's a helpful log function under jQuery's namespace:
$(element).log(); $.log('something'); -
Every initial selection you make is assigned to jQuery._this:
$(element).width( $._this.parent().innerWidth() ); -
The
endmethod now accepts a numerical argument signifying how far back you want to go:$(element).find('a').find('span').end(2); // (goes back to $(element)) -
The
filtermethod now accepts a matching criteria in the form of an object:$(lotsOfElements).filter({ id: /^(apple|banana|mango)$/, src: /\.(png|jpg)$/, rel: 'something' }); -
The
clonemethod now accepts a number as its first argument, indicating how many clones you want:jQuery('<div/>').clone(5); // 5 div elements. // Copy events (2nd argument): myjQueryCollection.clone(10, true); -
The
mapmethod accepts a string signifying what attributes to map:$(lotsOfAnchors).map('attr:href'); // => ['http://google.com', 'http://msn.com', ...] $(lotsOfAnchors).map('text'); // => ['Google', 'MSN' ...] // FORMAT: [jQuery method name]:[first param] -
All setter methods accept functions; these function must return the intended value:
$(element).css(function(){ return { color: $(this).css('backgroundColor') } }); // Note: Useless on multi-argument methods. -
All getter methods can return a full array of results instead of a single one; to enable this you must pass true as the very first argument:
$(lotsOfElements).width(); // 120 $(lotsOfElements).width(true); // [120, 230, 125, ...] -
You can query data in selectors by using the
:dataselector. Passing no arguments tests if that elements has any data.$('div:data'); // => All DIVs with data $('div:data(abc)'); // => Tests that "abc" property is a truthy value $('div:data(abc=123)'); // => Tests that "abc" prop is equal to "123" $('div:data(abc=/\\d/)'); // => Tests that "abc" prop has at least one digit $(':data("abc"="Blah\"something")'); // Use quotes for complex values -
%=operator can be used in attribute selectors for testing against a regular expression:$('a[href%=/^https?:/i]');
forked from paulirish/jQuery-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
pomeh/jQuery-plus
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
A collection of addons/plugins for jQuery - mostly overloaded jQuery methods...
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published