Uncaught SyntaxError: Unexpected identifier如果它能运作一次,为什么我会得到它?
StackOverflow上有很多这些.妙语通常是脚本中某处的拼写错误.
它工作一次,然后每秒发出1条错误信息.
我在这里改变地图上的状态颜色:
<!-- language: lang-js -->
<script type="text/javascript">
colors = [ 'rgba(255,0,0,0.1)','rgba(0,255,0,0.1)','rgba(0,0,255,0.1)' ];
$(document).ready(function(){
setInterval(
$("ul").children().eq( Math.floor(50*Math.random())).css('color', colors[Math.floor(3*Math.random())] )
,1000);
});
</script>
Run Code Online (Sandbox Code Playgroud)
use*_*654 20
你错过function(){}了包装你的代码.
setInterval(function(){
$("ul").children().eq( Math.floor(50*Math.random())).css('color', colors[Math.floor(3*Math.random())] )
},1000);
Run Code Online (Sandbox Code Playgroud)
它工作一次,因为它执行你的内部代码寻找要返回的函数或字符串.当一个不是时,它失败并出现js错误.