大佬們求解!為什么這樣不會顯示?
<!DOCTYPE? HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>數(shù)組</title>
<script type="text/javascript">
var? arr = ['*','##',"***","&&","****","##*"];
???? arr[7] = "**"; ?
?//創(chuàng)建數(shù)組
??? function lalala(){alert("數(shù)組長度為:"+arr.length);}
?//顯示數(shù)組長度
?? document.write((arr[0])+"<br/>");
??? document.write(arr[7])+"<br/>");
???? document.write(arr[2])+"<br/>");
????? document.write(arr[4])+"<br/>");
?//將數(shù)組內(nèi)容輸出,完成達到的效果。
</script>
</head>
<body>
<button onclick="lalala()">數(shù)組長度</button>
</body>
</html>
2018-10-10
小括號拿掉,并且你的是事件,需要觸發(fā)
2018-09-28
document.write(arr[0]+"<br/>");
document.write(arr[7]+"<br/>");
document.write(arr[2]+"<br/>");
document.write(arr[4]+"<br/>");
2018-09-09
你寫的代碼中輸出部分改為如下就可以了,把write()中的小括號去掉
document.write(arr[0]+"<br/>");
??? document.write(arr[7]+"<br/>");
???? document.write(arr[2]+"<br/>");
????? document.write(arr[4]+"<br/>");