javascript – changing a class’ style

Try the following

var all = document.getElementsByClassName('someClass');
for (var i = 0; i < all.length; i++) {
  all[i].style.color="red";
}

Note: As Cheery pointed out getElementsByClassName won’t work in IE. The linked question has a nice way to work around this limitation

  • javascript document.getElementsByClassName compatibility with IE

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)