107
rated 0 times
[
110]
[
3]
/ answers: 1 / hits: 59261
/ 8 Years ago, wed, march 2, 2016, 12:00:00
I am trying to add image to buttons I have using Javascript but I can't seem to get it working. I have sucessfully added image using HTML5, however, for my needs I need to add the image via javascript.
Below is what I have written to add images via HTML.
<button class=button id=Ok><img src=images/ok.png></button>
Below is what I have tried to add image via Javascript but it doesn't seem to work.
var buttons = document.getElementsByClassName(button);
for (var b = 0; b < buttons.length; b++) {
buttons[b].src = imagesok.png;
}
I am not to sure what I am doing wrong, any help would be nice. Thanks.
More From » html