elementReady

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-10 21:28:17

软件介绍

Calls a function during page load as soon as a specific element is available — even before the full DOM is loaded. Useful for applying unobtrusive JavaScript to particular page elements immediately, without waiting for the whole DOM to load in a large page.

$.elementReady(String id, Function fn)

  • id is the ID of the element to wait for
  • fn is the callback function to be called when the element appears in the DOM; in the callback, "this" refers to the newly loaded element.

While a page is loading, call a given callback function as soon as a specific element is loaded into the DOM, even before the full DOM has been loaded. Executes the function within the context of the element. This means that when the passed-in function is executed, the ‘this’ keyword points to the specific DOM element.

The function returns ‘this’, so you can chain multiple calls to elementReady(). (Not that there’s much benefit in doing that.)

One argument is passed to the callback: a reference to the jQuery function. You can name this argument $ and therefore use the $ alias even in noConflict mode.

If the element has not been found by the time the DOM is fully loaded, then the function will not be called.

Example:

Change the source of a specific image as soon as it is loaded into the DOM (before the whole DOM is loaded).

$.elementReady('powerpic', function(){
    this.src = 'powered-by-jquery.png';
});

Example:

If you want to have the jQuery object instead of the regular DOM element, use the $(this) function.

$.elementReady('header', function(){
    $(this).addClass('fancy');
});

Example:

Chain multiple calls to $.elementReady().

$.elementReady('first',  function(){ $(this).fancify(); })
.elementReady('second', function(){ $(this).fancify(); });

Example:

Use the ‘$’ alias within your callback, even in noConflict mode.

jQuery.noConflict();
jQuery.elementReady('header', function($){
    $(this).addClass('fancy');
});

Example:

Change the polling interval to 100ms. This only works if $.elementReady() has not yet been called.

// You probably don't need to do this
$.elementReady.interval_ms = 100;

本文地址:https://codercto.com/soft/d/23106.html

Web信息架构(第3版)

Web信息架构(第3版)

[美] Peter Morville、Louis Rosenfeld / 陈建勋 / 电子工业出版社 / 2013-10 / 99.00元

本书内容涵盖了信息架构基本原理和实践应用的方方面面。全书共7个部分,包括信息架构概述、信息架构的基本原理、信息架构的开发流程和方法论、信息架构实践、信息架构与组织、两个案例研究,以及参考资料清单。 本书兼具较高的理论价值和实用价值,曾被Web设计领域多本书籍重点推荐,是信息架构领域公认的经典书籍,不论新手还是专家都能各取所需。本书可供Web设计与开发者、Web架构师、网站管理者及信息管理相关......一起来看看 《Web信息架构(第3版)》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具