search

Home  >  Q&A  >  body text

Unable to add event

function addEvent(obj, type, fn) {    alert('a');    if (typeof obj.addEventListener != 'undefined') {        alert('b');    obj.addEventListener(type, fn, false);    } else if (typeof obj.attachEvent != 'undefined') {    obj.attachEvent('on'   type, fn);    alert('c');    } }

无法使用

风1458 days ago934

reply all(2)I'll reply

  • 灭绝师太

    灭绝师太2021-01-27 09:33:28

    What error is reported? Ask a question and post the error~

    reply
    0
  • 风

    I just can't add the window event, no error is reported, it just doesn't work.

    · 2021-01-29 13:42:32
  • Cancelreply