Skip to content

Instantly share code, notes, and snippets.

@ark234
Created November 15, 2017 14:43
Show Gist options
  • Save ark234/e27c392cd8750855c70408d051ba6287 to your computer and use it in GitHub Desktop.
Save ark234/e27c392cd8750855c70408d051ba6287 to your computer and use it in GitHub Desktop.
Using your Text editor, open “JavaScript task 3.1.1” Using JavaScript, include a button that sources an image. Program your button to change the source of your image on click. Save your page and name “JavaScript Task 3.1.2” in the “JavaScript Task 3.1” folder.
<!DOCTYPE html>
<html>
<head>
<title>Task 3.1.2</title>
</head>
<body>
<h1>What can JavaScript Do?</h1>
<p>JavaScript can manipulate HTML attrbutes</p>
<p>Change the src (source) attribute of an image with JAVASCRIPT</p>
<button onclick="document.getElementById('myImage').src='images/shark1.jpg'">GIVE ME A HAMMERHEAD SHARK</button>
<img src="images/shark1.jpg" id="myImage" style="width:300px">
<button onclick="document.getElementById('myImage').src='images/shark2.jpeg'">GIVE ME A TIGER SHARK</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment