<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
function myFunction()
{
document.write("calling function")
}
document.getElementById('demo').innerHTML=myFunction();
</script>
</body>
</html>
function myFunction(){document.write(“calling function”)} document.getElementById('demo')。innerHTML = myFunction();
答案 0 :(得分:1)
该函数在页面上写入“调用函数”,但它什么都不返回。因此
document.getElementById('demo').innerHTML=myFunction();
此语句将undefined返回到innerHTML