Internet Explorer does not support getElementsByClassName. getelementsbyclass
The getElementsByClassName method has been added to DOM3. However, other versions except IE9 and 10 do not support this method. This is a pain point!
Currently, this solution can be used to determine that the browser does not support this method. If it does not support this method, add the getElementsByClassName Method to the document Object. This method has the following advantages, no matter whether there are native functions, you do not need to modify the code.
Some people on the Internet directly define a getElementsByClassName function, but in this case, all the use of document. getElementsByClassName in the Code must be rewritten to getElementsByClassName. It is inconvenient and not common.
The following method perfectly supports document writing:
if(!document.getElementsByClassName){ document.getElementsByClassName = function(className, element){ var children = (element || document).getElementsByTagName('*'); var elements = new Array(); for (var i=0; i<children.length; i++){ var child = children[i]; var classNames = child.className.split(' '); for (var j=0; j<classNames.length; j++){ if (classNames[j] == className){ elements.push(child); break; } } } return elements; };}
The IE browser does not support var = documentgetElementsByClassName ('');
IE6, 7,8 does not seem to have this function.
If you want to use jquery, you can simply use $ (". Style name,
Why does IE not support getElementsByClassName ()? I won't use JS Code. The simple JS Code gets the class value.
GetElementsByClassName () has never been written in this way.
GetElementsById (op). className to get the css class of the current object