What do i need to do before my page start being interactive?

تبليغ
سؤال

يرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.

تبليغ
‎إلغاء

So I just started learning Javascript while using Freecodecamp youtube tutorials, so according to the tutorial he was talking about making increment number using javascript (i am going to attach images for further understanding) , in his own end, after writing the code and linking the js file to the index.html file and opening it with live server, once he click on the increment button from the live server the number is goenter image description hereing to change (as expected because thats the code he put in) but If i try to do it from my own end the number won’t increase but if I open developer tools and check it and i click the button the I will see the result in developer tools but not on the webpage (I hope i am making sense) The first side of the picture is my result, once i click the increment button i expect the number to change just like it did in the right hand side of the picture. PS: I just started learning javascript, if there’s anything else i need to know please include it. I just want a situation where i can click the button from my webpage and the number will increase just like it did in the video

let countEl = document.getElementById(“count-el”)

console.log(countEl)

let count = 0

function increment() {

count = count + 1
console.log(count)
}
<html>
<head>
<link rel=”stylesheet” href=”styles.css”>

</head>

<body>

<h1>People entered</h1>
<h2 id=”count-el”>0</h2>

<button id=”increment-btn” onclick=”increment()”>INCREMENT</button>

<script src=”script.js”></script>

</body>
</html>

‫أضف إجابة

تصفح
تصفح

مجهول يجيب