CustomEvent.detail

接口 CustomEvent 的只读属性 detail (详情)返回在初始化事件对象时传递过来的任何类型数据。

Note: 此特性在 Web Worker 中可用。

Syntax

 let myDetail = customEventInstance.detail;

Return value

事件对象初始化时传递的任何类型数据。

Example

// add an appropriate event listener
obj.addEventListener("cat", function(e) { process(e.detail) });

// create and dispatch the event
let event = new CustomEvent("cat", {
  detail: {
    hazcheeseburger: true
  }
});
obj.dispatchEvent(event);

// Will return an object contaning the hazcheeseburger property
let myDetail = event.detail;

Specifications

Specification Status Comment
DOM
detail
Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
detailChrome Full support 11Edge Full support 14Firefox Full support 11IE No support NoOpera Full support 11.6Safari Full support 6.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 14Opera Android Full support YesSafari iOS Full support 6.1Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also