javascript - getElementsByTagName is not a function -


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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -