javascript - Change font of multiple elements using document.getElementsByClassName()? -


how change font in css using document.getelementsbyclassname()?

i tried using:

document.getelementsbyclassname("classname").style.fontfamily="your font"; 

but doesn't work.

i using firefox 27.0.1 , supposed supported don't think problem. there wrong code?

first of note it's .getelementsbyclassname() not .getelementsbyclass().

.getelementsbyclassname() method returns nodelist of matching elements, therefore, have loop through returned list apply attribute, follows:

var list = document.getelementsbyclassname("classname");  (var = 0; < list.length; ++i) {     list[i].style.fontfamily="your font"; } 

Comments

Popular posts from this blog

c++11 - Intel compiler and "cannot have an in-class initializer" when using constexpr -

rest - Spring boot: Request method 'PUT' not supported -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -