您能否请一看这个演示,让我知道为什么我在DoSomething
上收到未定义的错误?
function DoSomething() {
console.log("This is Map");
}
$(document).ready(function() {
setInterval('DoSomething()', 1000);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
&#13;
我收到此错误
未捕获的ReferenceError:未定义DoSomething
答案 0 :(得分:0)
这很好但是为了保留语法,我们必须删除单引号,试试这段代码:
function DoSomething() {
document.write("This is Map");
}
$(document).ready(function() {
setInterval(DoSomething, 1000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>