Why can't the original className? be changed by getElementsByClassName?





</body>
</html>

Why doesn"t this work?
to change class= "close" to id= "close"; through var gg=document.getElementById ("close"); to be effective?

Mar.31,2021

clipboard.png
this method returns a class array object, not a single element.
you can try
gg [0] .className = 'show'


getElementsByClassName () method returns a collection of elements of all the specified class names, and notice that the result is a NodeList object.
on this page like you, there is only one class of the same name that can be achieved through gg [0]. ClassName = "show"; to achieve the effect


getElementsByClassName () method returns an array, you save the variable without selecting the subscript, so it will not be executed.
and it is more reliable to use the ele.setAttribute () method to modify the dom property.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bfa255-321c6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bfa255-321c6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?