[1日1 js]グローバルEventHandlersonclick


https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onclick
https://github.com/2taesung/JSOfficialDoc

GlobalEventHandlers.onclick


mixinのonclickプロパティは、所与の要素でイベントを処理するためのイベントハンドラです.GlobalEventHandlers
=>各イベントハンドル(ex,onclick)はGlobalEventHandlers混入で定義され、HTML Element、Document、Windowからロードおよび使用できます.

通史論


値段

target.onclick = functionRef;
functionRef関数名または関数式.関数は、MouseEventオブジェクトを固有の引数として受信します.関数にバインドされているこのオブジェクトもonclickされます(event.currentTargetと一致します).
=>バインドされたthisオブジェクトの物語は、後でthisを学ぶときにより正確になります.

はい。

    function changeColor(demo) {

      // console.log(demo)
      demo.style.backgroundColor = 'red'
    }
    let demo = document.getElementById("demo")
    // demo.addEventListener("click", changeColor(demo))
    demo.onclick = function() {
      changeColor(demo)
    }

クリック座標を取得


e.clientX ?