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

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -