How can I set values of HTML input elements using jQuery? | XM Community
Skip to main content

What jQuery syntax works for setting values of HTML input elements?

For the exemplary HTML input element below the issue seems to be shadow DOM https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM . Instead of being accessible as usual the value of the input element is wrapped into a shadow DOM + div element.



 


Above what you have highlighted, the input has an ID. This can be used to set the value of the input with jQuery. Try adding the below to the question’s JavaScript in the OnReady section:

var qid = this.questionId;
var input1 = document.getElementById("QR~"+qid+"~1~1");
jQuery(input1).val("44");

 


Leave a Reply