© 2026 LinearBytes Inc.
Search posts, tags, users, and pages
Theresa
Front End Web Developer (JS/HTML/CSS @ JAVA) : Predict the future by inventing it
Did you try
var span = document.getElementsByClassName("yourSpan"); console.log(span.item(0).firstChild.textContent);
TheSheriff
Co-Founder, Founder, Entrepreneur & Problem Solver
I appreciate your answer however that doesn't work and please see @fibric answer :)
Odd... this works fine for script tag inserted just before body closing tag with an init function that is called within the opening tag of the body :) did acknowledge fibrics answer. There is always more than one way to do things. No matter
@isogramc This only works for elements with no children. Thanks for the ack. And yea I agree! haha. @mevrael answer is interesting too.
span.item(0).firstchild.textContent