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

How can I get values of UI elements using jQuery?

  • Jul 19, 2023 1:14 PM UTC
  • 3 replies
  • 96 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);

 

View original

3 replies

Forum|alt.badge.img+4
  • Author
  • Level 3 ●●●
  • Jul 19, 2023 1:19 PM UTC

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 ●●●●●●●●
  • Answer
  • Jul 19, 2023 1:52 PM UTC

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 ●●●
  • Jul 19, 2023 2:34 PM UTC

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