I want to change a image after my page is loaded. I wrote a Java Script file but I don't know where my error is.. I also don't get an error in the console...
JavaScript:
function changeImage(){ changeImage = document.getElementsByClass("carousel-indicators"); changeImage = changeImage.getElementsByTagName("img")[0].src; actualImage = document.getElementsByClass("item active"); actualImage = actualImage.getElementsByClass("img-wrapper-inner"); actualImage.getElementsByTagName("img").src = changeImage; } I also call the function with:
<img onload="changeImage()"> Greetings and Thank You!
document.getElementsByClassName, notgetElementsByClasschangeImagefunction isn't being called. If you put aconsole.login it, does it show up in the console?Document.getElementsByClassdoes not exist. You can find the documentation onDocument.getElementsByClassNameon mdn: developer.mozilla.org/en/docs/Web/API/Document/…changeImage()function nowalert("Worked!");- But I do not get a alert... So at least my function isn't called... But why? I say<img onload="changeImage()">