Professional Documents
Culture Documents
</head>
<body>
<div id="slider">
<img id="first" src="images/1.jpg" alt="first image" />
<img src="images/2.jpg" alt="2=second image"/>
<img src="images/3.jpg" alt="third image"/></div>
</body>
</html>
2. Add this script to the header
<script>
var i = 1;
var noOfImages = 3;
var imgs = document.getElementsByTagName("img");
</script>
3. Add this script above the closing body tag.
<script type= text/javascript>
function displayImage() {
if (i == 0) { prev = noOfImages - 1; } else { prev = i - 1; }
imgs[i].style["display"]="block";
imgs[prev].style["display"]="none";
if (i == (noOfImages - 1)) i = 0; else i++;
}
</script>
4. Invoke the script by adding a onclick event for the <div id="slider" ..> element.
<div id="slider">
5. Add a button element:
<button onclick="displayImage();">Press</button>
6. Complete the above steps and test the solution. Does the image slide when you click the
button?
7. Now create two new events:
a. Every time you click on the slider image let it slide.
b. When the mouse enters an image let it slide.
Submission: The compiled HTML from above and screenshots of the result
<html>
<head>
<title>Text Animation</title>
<style>
p { font-size:14px; width:500px; height:40px; margin:auto;}
</style>
</head>
<body>
<p> I am an animated text <br />
Touch me !!!! I will yell <br /></p>
</body>
</html>
2. Initialize variables by placing this script in the <head>
<script>
var min=14;
var max = 30;
var sz = min;
var reverse = false;
</script>
3. Write JavaScript code to increase font upto a max and decrease upto a min
<script>
function changeFontSize() {
var paras = document.getElementsByTagName("p");
if (sz >= max) { reverse = true; }
if (sz <= 14) { reverse = false; }
if (reverse) { sz--; } else { sz++; }
paras[0].style.fontSize = sz + "px";
new Audio("chime.mp3").play(); //plays an audio chime everytime
}
</script>
Submission: The compiled HTML from above and screenshots of the result
67-317: Mobile Web Development and Usability Testing