偶然今天跟同时在处理一个时间延迟问题的时候遇到的问题 只因为在setTime后面的括号少加了一个引号,导致没有生效
demo如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>只输入数字正则</title>
</head>
<body>
<p>等待3秒出来'hello'</p>
<input type="button" onclick="setout()">
</body>
<script>
function setout(){
setTimeout('alert("hello")',3000);
}
</script>
</html>