Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<butten id="myElement">ddd</butten>
</body>
</html>
 
// 在 myElement 增加一個監聽 userLogin 事件的監聽器
myElement.addEventListener("userLogin", function(e) {
    // 聽到後印出 `e` 事件內容
    console.info("Event is: ", e.currentTarget );
    // 聽到後 印出 e.的細節
//     console.info("Custom data is: ", e.detail);
})
// 首先创建一个事件
// 我的事件 = 名叫 userLogin, 
// 他接收一個參數 {username: "davidwalsh"}
let myEvent = new CustomEvent("userLogin", {
    detail: {
        username: "davidwalsh"
    }
});
// 在 myElement 触发它!
myElement.dispatchEvent(myEvent);
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
oooooopro
0viewers