JSFiddle - React, Tailwind, and code Playground
by Prathameshsb
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Soccer Scoreboard</h1>
<div id="scoreboard">
<div class="team">
<h2>Home</h2>
<span id="home-score">0</span>
</div>
<div class="team">
<h2>Away</h2>
<span id="away-score">0</span>
</div>
</div>
<button id="home-goal" onclick="scoreGoal('home')">Home Goal</button>
<button id="away-goal" onclick="scoreGoal('away')">Away Goal</button>
<script src="script.js"></script>
</body>
</html>
CSS
body {
text-align: center;
}
h1 {
color: #333;
}
.team {
display: inline-block;
margin: 20px;
}
h2 {
font-size: 24px;
margin-bottom: 5px;
}
#scoreboard {
margin-top: 30px;
}
#home-score, #away-score {
font-size: 36px;
font-weight: bold;
}
button {
padding: 10px 20px;
font-size: 18px;
background-color: #4CAF50;
color: #fff;
border: none;
cursor: pointer;
}
JavaScript
var homeScore = 0;
var awayScore = 0;
function scoreGoal(team) {
if (team === 'home') {
homeScore++;
document.getElementById('home-score').innerText = homeScore;
} else if (team === 'away') {
awayScore++;
document.getElementById('away-score').innerText = awayScore;
}
}