getElementByClass().setAttribute doesn't work
Posted
by Syom
on Stack Overflow
See other posts from Stack Overflow
or by Syom
Published on 2010-04-02T09:22:43Z
Indexed on
2010/04/02
9:33 UTC
Read the original article
Hit count: 468
JavaScript
|html
why when i write
document.getElementByClass('home1').setAttribute('style', 'background-image:url(img/red_menu.PNG);');
it doesn't work?
i have the element with class="home1"
with document.getElementById('home1')...
works fine
thanks
EDIT:
and when i wrote
document.getElementByClassName('home1').setAttribute,
i have a javascript error
Error: document.getElementsByClassName("home1").setAttribute is not a function
© Stack Overflow or respective owner