Skip to content

Commit

Permalink
add counter WIP b00tc4mp#167
Browse files Browse the repository at this point in the history
  • Loading branch information
annagonzalez9 committed Oct 6, 2024
1 parent 61d5d32 commit e14977f
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion staff/anna-gonzalez/unsocial/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
color: yellow;
}

.counterBox {
margin-top: 20px;
background-color: yellow;
color: black;
}

button {
font-family: 'Press Start 2P';
font-size: 120%;
Expand Down Expand Up @@ -115,6 +121,12 @@ <h2>Home</h2>

<h3>Hello, User!</h3>

<div class="counter">
<p>How unsocial do you feel today?</p>
<button class="counterBox">-</button>
<button class="counterBox">+</button>
<p id="counter">0</p>
</div>
<button>Logout</button>
</section>

Expand Down Expand Up @@ -222,7 +234,7 @@ <h3>Hello, User!</h3>

//-------------------------------EXERCISE: LOGOUT BUTTON BEHAVIOUR-------------------------------
var homeButtons = homeSection.querySelectorAll('button')
var logoutButton = homeButtons[0]
var logoutButton = homeButtons[2]
logoutButton.onclick = function (event) {
event.preventDefault()

Expand All @@ -232,6 +244,25 @@ <h3>Hello, User!</h3>
loginSection.style.display = ''
}

//-------------------------------EXERCISE: COUNTER IN THE HOME-------------------------------
var counter = 0
var counterDisplay = document.getElementById('counter')

var decreaseButton = homeButtons[0]
decreaseButton.onclick = function (event) {
event.preventDefault()

counter--
counterDisplay.innerText = counter
}

var increaseButton = homeButtons[1]
increaseButton.onclick = function (event) {
event.preventDefault()

counter++
counterDisplay.innerText = counter
}
</script>
</body>

Expand Down

0 comments on commit e14977f

Please sign in to comment.