<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test0906</title>
</head>
<body>
<p id="demo">ds</p>
<script type="text/javascript">
function double11(a,b){
return a*b;
}
document.getElementById("demo").innerHTML=double11(3,4);
</script>
</body>
</html>
一楼正解,我看错了,不好意思
其实是函数的结果将P标签的内容覆盖了,而看起来只有12了。你可以在P标签后加几个带内容的P标签,试试,看结果你就明白了。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test0906</title>
</head>
<body>
<p id="demo">ds</p>
<p id="demo">ds</p>
<p id="demo">ds</p>
<p id="demo">ds</p>
<p id="demo">ds</p>
<script type="text/javascript">
function double11(a,b){
return a*b;
}
document.getElementById("demo").innerHTML=double11(3,4);
</script>
</body>
</html>
double11(a,b)函数给P标签重新赋值了,所以返回的是函数结果