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# - Sort XmlNodeList with a specific Node value -

Android Java.Lang.RuntimeException : Unable to start activity Component Info -

actionscript 3 - Equivalent to moveReceived in ElectroServer 5 -