Explore the community Forums Lectora Lectora Questions & Answers retrieving the timer value into a variable Reply To: retrieving the timer value into a variable

#419860 Score: 1
Profile photo of Math Notermans
Math Notermans
Member
contributor
intermediate
advanced
friend finder
junior moderator
advocate
LUC16 Attendee
LUC16
wise owl
curious george
129 pts
@mnotermans5114

Hi Ks,

First you need some way to select the element. The function given returns the text of a textfield with
the given css-class.

var myText  = getText(“.someCssClass”);
console.log(myText);

The function and approach below dont use any extra libraries and still get the text of any given textfield:
function getText(_cssClass){
var elem = document.querySelector(_cssClass);// targets a textfield with class someTextfield
var text = elem.textContent; // target the text content
return text;
};

 

kind regards,
Math

This post has received 1 vote up.