I want to display data in the console.log() when a button is clicked . so my code is
let btn = document.getElementById('myBtn');
btn.addEventListener('click', function() {
console.log('button clicked !!')
})
<button id="myBtn">click</button>
This code works fine as expected , But When open the file from the local host XAMPP ; the data is not displayed on the console , i tried to use alert() instead , it woks fine , i tried also to move the console.log('clicked!!') outside the event callback function , it woks fine also!! but as long as it is inside the function it does not work on the click event .
here is a i recorder for better understanding => https://youtu.be/6xYowU8l7hM