var element = document.querySelectorAll('div');
console.log(element)
alert(11)
Initially, the browser displays the console contents and then triggers an alert. To change this behavior, the code can be modified as follows:
var element = document.querySelectorAll('div')[0];
console.log(element)
alert(11)
With these adjustments, the browser will first trigger the alert, followed by displaying the console content. The same pattern applies to
document.getElementsByClassName()
. I have been attempting to resolve this for quite some time without success, any suggestions would be greatly appreciated.