When I run the below script in Internet Explorer, the output of console.log(target_el)
is as expected:
<div class="hidden"></div>
However, in Chrome the output is:
<div class="visible"></div>
Even funnier, the output of console.log(target_el, target_el.className)
in Chrome will be:
<div class="visible"></div> "hidden"
Why is that so?
function change_el_class(target_el, target_class) {
console.log(target_el)
target_el.className = target_class
}
let el = document.getElementsByClassName('hidden')[0]
change_el_class(el, 'visible')
<div class="hidden"></div>