html,谁能帮我看看哪里有问题,点击按钮没反应
<!DOCTYPEhtml><html><body><p1>循环遍历对象“马云”属性</p1><buttononclick="myFunction()">点击这里</bu...
<!DOCTYPE html>
<html>
<body>
<p1>循环遍历对象“马云”属性</p1>
<button onclick="myFunction()">点击这里</button>
<p1 id="test"></p1>
<script>
function myFunction()
{
var x;
var txt="";
var person={fname:"jack",lname:"ma",company:"alibaba"};
for (x in person)
{
txt=person[x] + txt;
}
document.getElementById("test").innerHTML=txt;
</script>
</body>
</html> 展开
<html>
<body>
<p1>循环遍历对象“马云”属性</p1>
<button onclick="myFunction()">点击这里</button>
<p1 id="test"></p1>
<script>
function myFunction()
{
var x;
var txt="";
var person={fname:"jack",lname:"ma",company:"alibaba"};
for (x in person)
{
txt=person[x] + txt;
}
document.getElementById("test").innerHTML=txt;
</script>
</body>
</html> 展开
2个回答
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">正确的代码,你代码问题出现在函数结尾少了一个结束大括号 }
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function myFunction()
{
var x;
var txt="";
var person={fname:"jack",lname:"ma",company:"alibaba"};
for (x in person)
{
txt=person[x] + txt;
}
document.getElementById("test").innerHTML=txt;
}
</script>
</head>
<body>
<p1>循环遍历对象"马云"属性</p1>
<button onclick="myFunction()">点击这里</button>
<p1 id="test"></p1>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询