96
rated 0 times
[
97]
[
1]
/ answers: 1 / hits: 90221
/ 12 Years ago, tue, august 7, 2012, 12:00:00
I have an array.js
file and an index.html
.
My array.js
file looks like this:
function go(){
var array = new Array();
array[0] = Red;
array[1] = Blue;
array[3] = Green;
for (var i=0; i < array.length; i++){
document.write(<li> + array[i] + <br />);
}
}
My index.html
file looks like this:
<html>
<head>
<script type=text/javascript src=array.js></script>
</head>
<body>
<input type=button onclick=go() value=Display JS Array/>
<script>
go();
</script>
</body>
</html>
When I click the Display JS Array
button on the HTML page, nothing happens.
I want the array elements to be displayed after I click the button.
It should look like:
- Red
- Blue
- Green
More From » html