I want to get the anchor (here "linktext") of a textlink on a special page:
<div id="msgbox"><h2>xxx</h2><p>xxxx <a href="./url">linktext</a>xxx</p></div>
I tried it with Javascript to get link text and this code:
var e = document.getElementById('msgbox').
getElementsByTagName('p')[0].
getElementsByTagName('a')[0];
var theText = e.innerHTML;
console.log(theText);
// or, in sufficiently-modern browsers
e = document.querySelector('#msgbox p a');
theText = e.innerHTML;
return theText ;
}
But i just get something like
"HTMLDivElement: html > body.sliding-popup-processed > div"
as value. There can be more than one linktext on the page, which should be tracked.
Can you help me out?