文章目录
在控制台输出
function showLog(message) {
console.log(message);
}
function test(name) {
showLog(name);
}
test("hello");
如果想要注释掉所有的输出,直接把 console.log(message);注释掉即可
console.info(message);
console.warn(message);
console.error(message);
console.debug(message);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
function method() {
var result = 0;
for (var i = 0; i < 10; i++) {
result += i;
}
document.getElementById("id1").innerHTML = result;
}
</script>
</head>
<body>
<input type="button" value="click" onclick="method();">
<div id="id1"></div>
</body>
</html>