Get into span in javascript
Get into span in javascript
I want to get value of span with class "en-value" (48/100), placed in a use getElementsByClassName method or querySelector which works in all modern browsers add an Here you go, a solution using pure js: Documentation: https://www.w3schools.com/jsref/met_document_getelementsbyclassname.asp You can get it by giving the Or if you do not want to add an id and want to select all elements of that . Here's the html code: Can you help me?
Possible duplicate of Get value of Span Text
– SehaxX
Jun 29 at 11:02
4 Answers
4
document.getElementsByClassName("en-value")[0].innerTextdocument.querySelector("span.en-value").innerText
Thanks, second one works well. Love!
– Freese
Jun 29 at 11:05
id to the span and call getElementById:idspangetElementById<span class="en-value" id="myId">48/100</span>
var mypsan = document.getElementById("myId").innerHTML;console.log(document.getElementByClass('en-value')[0].innerText);span an id attribute such as id=mySpan and thenspanidid=mySpanvar mySpanValue = document.querySelector("#mySpan").innerHTML;class, thenclassvar myArrOfEnVal = document.querySelectorAll(".en-value");
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

this is easily googable
– ThisGuyHasTwoThumbs
Jun 29 at 11:01