setInterval and [removed] problem

后端 未结 4 1748
醉梦人生
醉梦人生 2021-01-22 21:13

I have this code

window.onload = function() {            
    function foo() {
        alert(\"test\");
    }
    setInterval(\"foo()\",500)
}

4条回答
  •  猫巷女王i
    2021-01-22 21:27

    Try this:

    function foo() {
        alert("test");
    }
    
    window.onload = function() {            
        setInterval("foo()",500)
    }
    

    It works for me.

提交回复
热议问题