How can I get values of UI elements using jQuery? | XM Community
Skip to main content
Solved

How can I get values of UI elements using jQuery?

  • July 19, 2023
  • 3 replies
  • 66 views

Forum|alt.badge.img+4

The usual jQuery syntax does not work when I try to get values of HTML elements. What syntax works in QX actually?

Best answer by Tom_1842

Try adding the below to the question’s JavaScript in the OnReady section:

var qid = this.questionId;
var statement1 = document.getElementById("header~"+qid+"~1");
var statement1text = jQuery(statement1).text().trim();
console.log(statement1text);

 

3 replies

Forum|alt.badge.img+4
  • Author
  • Level 3 ●●●
  • 29 replies
  • July 19, 2023

I found some example for actually working syntax. Actually the syntax which works actually is e.g. for the example below

is like

 


Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • 909 replies
  • Answer
  • July 19, 2023

Try adding the below to the question’s JavaScript in the OnReady section:

var qid = this.questionId;
var statement1 = document.getElementById("header~"+qid+"~1");
var statement1text = jQuery(statement1).text().trim();
console.log(statement1text);

 


Forum|alt.badge.img+4
  • Author
  • Level 3 ●●●
  • 29 replies
  • July 19, 2023

@Tom_1842 Thx a lot for the fast response. jQuery is working just fine for me right now.