CSA -202 Web App Development
Assignment 5 : (JavaScript event handling)
1) Write JavaScript code that creates a button on the page and add a click
event listener to log a message to the console. (Use
createElement(), and addEventListener() methods
2) Write a JavaScript function that changes the background color of a DIV
element when mouse enters and leaves it. (handle onmouseenter and
onmouseleave events)
3) Use the following html and write JavaScript to handle image click event.
Also add the functionality for next and previous buttons
<html>
<head>
<title>Image Viewer</title>
</head>
<body >
<div>
<img src="images/[Link]" width="80px" height="80px" />
<img src="images/[Link]" width="80px" height="80px" />
<img src="images/[Link]" width="80px" height="80px" />
<img src="images/[Link]" width="80px" height="80px" />
</div>
<button >Prev</button>
<button >Next</button>
<div >
<img id="imgdiv" src="images/[Link]" width="300px" />
</div>
</body>
</html>
4) Use the following html and add Javascript to read the
form elements.
<html>
<head>
<title>HTML Form</title>
</head>
<body >
<form>
<div>
<label for="fname">First name: </label>
<input id="fname" type="text" />
</div>
<div>
<label for="lname">Last name: </label>
<input id="lname" type="text" />
</div>
<div>
<input id="submit" type="submit" />
</div>
</form>
</body>
</html>