Matrix table question -- validating the statements | XM Community
Solved

Matrix table question -- validating the statements

  • 15 June 2021
  • 2 replies
  • 23 views

Hi, I'm trying to validate if a 'Statement' in the Matrix table question exists using jquery. So the 'Statement' is a span element. I added this 'span' element using the 'html' editor in the matrix table question. Here is the html for the 'Statement' -- ASM)
And here is my js code inside onready function,
  if ($('#asm').length) {
alert("The element you're testing is present.");
      alert($('#asm').text());
     }
But I'm getting this error ---> Uncaught TypeError: Cannot read property 'length' of null. And I inspected the page and confirmed that the 'asm' id element exists so not sure why it is throwing a null.
And I tried this same code outside of Qualtrics using a html and it works perfectly fine. Just strange. Not sure what am i missing. Any help appreciated.

icon

Best answer by Username_taken 15 June 2021, 17:13

View original

2 replies

Userlevel 7
Badge +21

If you are using the preview, the it's possible you are not in the correct iframe.
Chromium and its derivatives will automatically choose the correct iframe after you inspect an element, however for Firefox and its derivatives, you'll need to manually select it. Top right corner of dev tools.

Thank you ahmedA . Found out what the issue was -- it is the '$' sign that was causing the issue. Once I changed it to JQuery (instead of $) it worked. Thanks again.

Leave a Reply