Skip to content

Instantly share code, notes, and snippets.

@timwco
Created March 5, 2017 22:14
Show Gist options
  • Save timwco/808e06a4eaf0c02f3367aeef7ff0e1e2 to your computer and use it in GitHub Desktop.
Save timwco/808e06a4eaf0c02f3367aeef7ff0e1e2 to your computer and use it in GitHub Desktop.
HTML Project with Joe
<!DOCTYPE html>
<html>
<head>
<title>Cool Web Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<p class="my-title">Hello World</p>
<p class="my-likes">
Likes: <span class="likes-count">0</span>
</p>
<p>
<button>Like this Post</button>
</p>
<p>
<a href="http://google.com">
<img src="images/picture.gif" alt="a funny gif">
</a>
</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
// Find My Like Button
let myButton = document.querySelector("button");
// Find The Link Count Element
let likeCount = document.querySelector(".likes-count");
// When the Button is Clicked, perform operations
myButton.addEventListener("click", updateLike);
// Get Current Count, Add 1 to it, update the Like Count
function updateLike () {
let currentCount = Number(likeCount.innerText);
let newCount = currentCount + 1;
likeCount.innerText = newCount;
}
body {
background-color: rgba(0, 163, 255, 0.77);
color: white;
font-family: cursive;
font-size: 16px;
}
.my-title {
font-size: 25px;
}
img {
width: 400px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment