作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
大家好,我还有一个问题。我现在正在处理函数和事件,这就是我到目前为止所拥有的..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Personal Information</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="js_styles.css" type="text/css" />
<script type="text/javascript">
//<![CDATA[
function printPeronalinfo( "name,age,hobbies,favorite movies") {
document.write("<p>" + name +"</p>");
document.write("<p>" + age +"</p>");
document.write("<p>" + hobbies + "</p>");
document.write("<p>" + favorite video + "</p>");
}
//]]>
</script>
</head>
<body>
<script type="text/javascript">
/ * <![CDATA[ */
printPeronalinfo( "age,age,hobbies,favorite movies")
var return_value = return_message();
document.write(return_value);
/*]]> */
</script>
</body>
</html>
现在我的问题是我知道我做错了什么,因为它没有显示在网页上。它应该读取我的名字、年龄、爱好、最喜欢的电影。现在,我是否将头部中的内容重复到正文,但我将把我的名字放在那里,而不是使用“名称”一词,或者使用“if”或“else”(但我很确定这是用于按钮的)。我也知道我可以使用数组,但我不知道这是否有效。
最佳答案
你有几个错误..
function printPeronalinfo( "name,age,hobbies,favorite movies") {
/* ^ no quotes here, ^ invalid variable name */
// should be: function printPeronalinfo(name, age, hobbies, favorite_movies) {
document.write("<p>" + name +"</p>");
document.write("<p>" + age +"</p>");
document.write("<p>" + hobbies + "</p>");
document.write("<p>" + favorite video + "</p>");
/* ^ undefined variable, isn't defined in your function */
// should be: document.write("<p>" + favorite_movies + "</p>");
}
...
printPeronalinfo( "age,age,hobbies,favorite movies");
/* ^ incorrect passing of data */
// should be: printPeronalinfo("name", "age", "hobbies", "favorite movies");
您还应该注意,您的函数名称将“Personal”错误拼写为“Personal”。
更新:在您的第二个 <script>
中 block ,您的评论 block 标签不正确:/ *
不应有空格。这是正确的:/*
关于javascript - 具有适当参数的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4948790/
这段代码在 Java 中的等价物是什么?我放了一部分,我对 I/O 部分感兴趣: int fd = open(FILE_NAME, O_WRONLY); int ret = 0; if (fd =
我正在尝试将维度为 d1,d2,d3 的张量 M[a1,a2,a3] reshape 为维度为 d2, d1*d3 的矩阵 M[a2,a1*a3]。我试过 M.reshape(d2,d1*d3) 但是
我是一名优秀的程序员,十分优秀!