jquery error () method syntax

jquery error () method syntax

Role: When an error is encountered element (not load properly), error events. error () method triggers the error event, or specified when the function of the error when an event occurs. This method is bind ( 'error', handler) shorthand. Linear module

Trigger event syntax error: $ (Selector) .error ()

Will function to bind to the error event syntax: $ (Selector) .error (function)

parameter:

parameter description
function     Optional. Provisions when the function of the error when an event occurs.

jquery error () method of Example

<HTML> 
<head> 
<Script type = "text / JavaScript" the src = "http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"> </ Script> 
<Script type = "text / JavaScript"> 
$ (Document) .ready (function () { 
  $ ( "IMG"). error (function () { 
    $ ( "IMG"). The replaceWith ( "<P> <B> image does not load ! </ B> </ P> "); 
  }); 
}); 
</ Script> 
</ head> 
<body> 
<IMG the src =" http://img.php.cn/upload/article/000/ 005/656 / 5af270fd37755429.jpg "/> 
<the p-> If the above image is not correctly loaded, it will be replaced for a" picture is not loaded, "the text. </ P> 
</ body> 
</ HTML>

Guess you like

Origin www.cnblogs.com/furuihua/p/11961936.html