I just can't get my separate JavaScript file to work with my XHTML file. I want to change a picture in the HTML file using JavaScript, so I wrote the following code:
var image = new Array()
image[0] = "image0.jpg";
image[1] = "image1.jpg";
image[2] = "image2.jpg";
image[3] = "image3.jpg";
var demo = function() {
document.getElementById("slide").src = image[1];
}
demo();
and in my HTML file I have
<head>
<title>Webdesign Tutorial</title>
<link rel="stylesheet" type="text/css" href="Home page.css">
<script type="text/javascript" src="ImagesSlide.js"></script>
</head>
<body>
<p><img id="slide" src="image0.jpg" width="500" height="300" name="slide" /></p>
</body>
All the file names are right, and when I put the "document.get...." line into script tags in my HTML file, it does change the image.
why did u choose this script - and yes - below the body – Pika May 04 '14 at 15:38