javascript - getElementsByTagName is not a function -
this question has answer here:
i struggling this. wanting change src attribute of img tag , error message getelementsbytagname not function. following test markup
<html> <body> <div class="logo"> <img src="/a.jpg"> </div> <script> document.getelementsbyclassname('logo').getelementsbytagname('img')[0].src ="/b.jpg"; </script> </body> </html>
any advice appreciated.
getelementsbyclassname return collection. have :
document.getelementsbyclassname('logo')[0].getelementsbytagname('img')[0].src ="/b.jpg";
Comments
Post a Comment