> Yes, the best way to do this is with a Mutation Observer.
I am a beginner at JS and I do not know about this command. How can I implement it? Thanks.
Paste the below code in the js(OnReady) of the slider question
jQuery("#"+this.questionId+" div.track").mousedown(function (e1) {
jQuery(document).mouseup( function(e2) {
var s = jQuery(".sliderToolTipBox ").text().replace("%","");
jQuery(".sliderToolTipBox ").text(s+"%");
});
});
TomG I am also looking for a solution. Do you have a sample code? Could you please share here in this forum
Hi LydonLab_RA and Pavan
You can achieve the same(to append "%") using the below code by adding below code into Qualtrics JS API:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
// Select the node that will be observed for mutations
const targetNode = document.getElementsByClassName("sliderToolTipBox")[0];
let observer = new MutationObserver(function() {
targetNode.innerHTML = Math.abs(targetNode.innerHTML)+"%";
observer.disconnect(); // turn observer off;
observer.observe(targetNode, {
attributes: true,
childList: true, // observe direct children
subtree: true, // and lower descendants too
characterDataOldValue: true // pass old data to callback
});// turn back on
});
// observe everything except attributes
observer.observe(targetNode, {
attributes: true,
childList: true, // observe direct children
subtree: true, // and lower descendants too
characterDataOldValue: true // pass old data to callback
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Hope it resolves your query!!!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.