The code snippet in the Fiddle is setting a listener on #test
, however, the element actually has an id of #test1
. This discrepancy needs to be resolved first. After that...
When using
document.getElementsByClassName(...)
, it returns a collection. If your intention is to set the
className = "show"
on each element with the class name of
k-grid-header
, you will need to iterate over them.
The easiest way to achieve this is by utilizing querySelectorAll()
because it provides a collection with a forEach()
method for iteration:
document.querySelectorAll('.k-grid-header').forEach(el=>{
el.className = "";
//... etc
});