Just use querySelectorAll
javascript:alert(document.querySelectorAll(".m-names .m-h3 strong")[0].innerHTML);
質問
I will be running the javascript through my browser (chrome) like this javascript:
codegoeshere, so i cannot use jQuery
. The website is not mine, so i cannot modify it.
In the source code of the web page the username is stored like this:
<div class="m-names"><div class="m-h3"><strong>@usernamegoeshere</strong>
My question is, how can i parse @usernamegoeshere
with javascript
into a variable? I want to be able to alert the final result.
Thanks to anyone that can help.
解決
Just use querySelectorAll
javascript:alert(document.querySelectorAll(".m-names .m-h3 strong")[0].innerHTML);