Sorun şu. Bu uygulamayı yapan kişi kodları tek bir sayfaya yazıp çalıştırmış. Ama ben style.css ve app.js dosyaları açıp bu dosyalarda çalıştırmak istedim. Kodlar şu şekilde. Bu bir sayaç uygulamasıHTML Sayfası
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<script src="java.js"></script>
<div class="container">
<p class="heading">Sayaç</p>
<p class="counter" id="counter">0</p>
<button class="incr">+</button>
<button class="decr">-</button>
</div>
</body>
</html>CSS Sayfası* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
width: 150px;
height: 150px;
background-color: #185ad8;
color: white;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
position: relative;
border-radius: 15px;
}
.counter {
font-size: 4rem;
font-family: sans-serif;
}
.headling {
font-family: sans-serif;
}
button {
width: 40px;
height: 40px;
position: absolute;
cursor: pointer;
font-size: 1.2em;
background: white;
color: rgb(34, 34, 34);
box-shadow: 0 0 10px rgb(51, 51, 51, 0.158);
border: none;
border-radius: 50px;
}
.decr {
bottom: -15%;
right: 10%;
}
.incr {
bottom: 10%;
right: -15%;
}Javascript Sayfası<script>
let counter = document.getElementById('counter');
let incr = document.querySelector('.incr');
let decr = document.querySelector('.decr');
let count = 0;
incr.addEventListener{"click", ()=> {
count++;
updateDisplay();
}};
decr.addEventListener{"click", ()=> {
count--;
updateDisplay();
}};
function updateDisplay(){
counter.innerHTML = count;
};
</script>Hata buradaki koddan kaynaklanıyor şuanda function updateDisplay(){
counter.innerHTML = count;
};Bu sorunu nasıl çözebilirim ?
