gpt4 book ai didi

javascript - 为什么没有输出

转载 作者:行者123 更新时间:2023-12-02 14:59:54 26 4
gpt4 key购买 nike

我写了一个关于 Javascript function 的示例 fiddle ,但是没有输出,我该如何解决这个错误。

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
function student(name,id,level,phone){
var name, id, level, phone;
this.name= name;
this.id= id;
this.level= level;
this.phone= phone;}
function myFunction(){
var stud = new student("khaled al gamd","110_35_1353","three",0501607419);
var name= stud.(name);
var id= stud.(id);
var level= stud.(level);
var phone= stud.(phone);
document.write (name);
document.write (id);
document.write (phone);
}
<p id="result"><\/p>
document.getElementById("result").innerHTML=myFunction();
</script>
</body>
</html>

最佳答案

如果您想通过 JavaScript 创建段落标记,则需要写出该段落标记:

function student(name, id, level, phone) {
this.name = name;
this.id = id;
this.level = level;
this.phone = phone;
}
function myFunction() {
var stud = new student("khaled al gamd", "110_35_1353", "three", 0501607419);
var name = stud.name;
var id = stud.id;
var level = stud.level;
var phone = stud.phone;
return name + "<br>" + id + "<br>" + phone;
}
document.write('<p id="result"> </p>');
document.getElementById("result").innerHTML = myFunction();

有关 JavaScript 的帮助,您可以尝试 JSHint:

http://jshint.com/

关于javascript - 为什么没有输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35502941/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com