$.active
Counter for holding the number of active queries
This property is useful when there is a need to check the number of running Ajax requests. For example, the following code can be used to prevent double Ajax request:
$("button").on("click", function() {
if ($.active.length === 0) {
$.ajax({ ... });
}
});
$.camelCase(string)
Convert dashed to camelCase
While jQuery uses this method in css and data modules, you can use it to transform strings in format xxx-yyy-zzz
to xxxYyyZzz
:
var str = $.camelCase("xxx-yyy-zzz"); // "xxxYyyZzz
$.easing
This property contains all supported easing effects with functions for calculating these effects. By default jQuery supports linear
and swing
effects only, but if you include jQueryUI $.easing
property will be extended with other effects.
For instance, we can easily check if bounce effect is supported with the following code:
var bounceSupported = "easeInOutBounce" in $.easing;
$.isReady
Is the DOM ready to be used? Set to true once it occurs.
This property can be used as a flag to check if DOM was fully loaded, if for some reason you don't use $(document).ready()
event. Easy example so far:
if (!$.isReady) {
$.error("DOM was not fully loaded yet");
}
$.readyWait
A counter to track how many items to wait for before the ready event
fires.
Yet I found no other use except the same as for $.isReady
.
$.text(elem)
Utility function for retrieving the text value of an array of DOM
nodes.
Fast method for picking up text contents from DOM tree. It is useful when you need to speed up your code, that works with DOM elements:
$("div").on("click", function() {
console.log( $.text(this) );
});
$.timers
This property holds timers of jQuery elements animation. It can be used for fast check if there is any animation process running at a time, instead of $(":animated").length
:
$("span").on("click", function() {
if ($.timers.length === 0) {
$(".flows, #spoiler, #par > p").fadeIn("slow");
}
});
One good usage example can be taken from this question.
$().push
This method behaves in the same way as Array.push()
, adding new DOM element to jQuery object. Does the same as $a = $a.add($b)
:
var $a = $("#element1"),
$b = $("#element2");
$a.push($b[0]);
Usage example: jQuery concatenation of selectors without creating a new instance?