weixin_慕丝7205835
2019-02-26 09:19
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数组</title>
<script type="text/javascript">
//创建数组
var myarr=["*","##","***","&&","****","##*","**"];
//显示数组长度
function shan(){
alert(myarr.length);
}
//将数组内容输出,完成达到的效果。
document.write(myarr[0])+"</br>"
document.write(myarr[7])+</br>
document.write(myarr[2])+</br>
document.write(myarr[4])+</br>
</script>
</head>
<body>
<form>
<input type="button" onclick=shan() value="数组长度"/>
</form>
</body>
</html>
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数组</title>
<script type="text/javascript">
//创建数组
var myarr = ['*','##',"***","&&","****","##*"];
myarr[7] = "**";
//显示数组长度
alert(myarr.length);
//将数组内容输出,完成达到的效果。
for (var i=0; i <= 7; i++)
{
document.write(myarr[i] + "<br/>")
}
</script>
</head>
<body>
</body>
</html>
<br >也要在括号里
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数组</title>
<script type="text/javascript">
//创建数组
var arr=['*','##',"***","&&","****","##*"];
arr[7]="**";
//显示数组长度
var L=arr.length;
function shan(){
alert(L);
}
// document.write("数值长度为:"+L+"<br>");
//将数组内容输出,完成达到的效果。
document.write(arr[0]+"<br>"+"<br>");
document.write(arr[7]+"<br>"+"<br>");
document.write(arr[2]+"<br>"+"<br>");
document.write(arr[4]+"<br>"+"<br>");
</script>
</head>
<body>
<form>
<input type="button" onclick="shan()" value="显示长度"/>
</form>
</body>
</html>
下边三个换行没有加引号
JavaScript进阶篇
468192 学习 · 21891 问题
相似问题