How to read the contents of a href with javascript?
问题 I have the following html and am stumped as to how to read the contents of the href tag? <p class="xyz-title"> <a href="http://www.youtube.com/embed/xyz"> <span class="field-content">Title here</span> </a> </p> I tried document.getElementByClass('xyz-title')[0].innerHTML but that didn't work obviously. Thanks very much for pointing me in the right direction. 回答1: It is a syntax error. It is supposed to be getElementsByClassName. Use this instead: document.getElementsByClassName('xyz-title')[0