0
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src = "A1P1Q1.js"></script>
</head>
<body>
<p id="a"></p>
<p id="firstname"></p>
<p id="details"></p>
<script>
variable();
</script>
JavaScript代碼當我分離JavaScript和HTML文件,僅年齡顯示
function variable(){
age = 24;
var fname = "sachin";
lname = "hunur";
details = [age, fname, lname];
document.getElementById("a").innerHTML = "the age is" +" " +age;
document.getElementById("firstname").innerHTML = "first name is" +
" " + fname;
document.getElementById("details").innerHTML = "The user details are" +
"age : " + details[0] + "first name : " + details[1] + " last name : "
+ details[2];
return;
}
塊引用:所示的輸出是僅: 年齡爲24
如何獲得印刷的名字和詳細信息?
是否有在JavaScript控制檯中的任何錯誤? – Barmar
這聽起來像是在顯示第一個輸出後出現錯誤。 – Barmar
它適用於我:http://jsfiddle.net/barmar/9ndt0gLt/ – Barmar