[removed] not working for me?

前端 未结 8 1953
栀梦
栀梦 2021-02-07 14:17

Well I\'m simply playing around with a userscript of GreaseMonkey and here\'s just something simple I attempt to do;

function test() {
document.getElementById(\'         


        
8条回答
  •  长发绾君心
    2021-02-07 15:05

    It is because you are assigning the result of the test function instead of the function itself due to the parentheses () on the last line.
    Remove them and it may work.

    If not then:

    Apparently that is by design. [Chrome - v57]
    Use document.addEventListener("DOMContentLoaded", ); instead.

    See: Page lifecycle : DOMContentLoaded

提交回复
热议问题