酌情扣押你的人力要素,无论你是否再次使用宝石,这无疑是明智的。
但我想到这个问题或许应该有帮助。 我对周围进行了搜索,找不到。
因此,我写了一封信真是迅速的。 http://blog.bucketsoft.com/05/lazy-loading-jquery-selector.html
(function($){
var cachedObjects = new Array();
$.lazy = function(selector) {
if (typeof selector != "string" || arguments.length > 1)
return $.apply(this, arguments);
var o = cachedObjects[selector];
if (o == undefined)
{
o = $(selector);
cachedObjects[selector] = o;
}
return o;
};
})(jQuery);
You d use it like this...
$.lazy( .my-nav ).show();
Let me know if I ve overlooked anything. But I believe this would be good to use whenever the elements you re selecting are static and are never added or removed dynamically.
<>>>>>
I ve changed the code to make this more efficient. And I ve added a line to return $(selector)
when the selector is not a string. So the caching will only work when the selector is a string.
<>12>>
现在,如果你不简单地通过护法,每 j客建议,就会打上<条码>。