Hi all,
I posted recently about hiding the minus signs from the numbers on a slider, which thankfully has now been solved (more survey context on there if required).
I am now trying to hide the minus signs from the toolTip (or toolTipBox) which accompanies the slider - currently the toolTip is disabled but it would make the slider values much clearer if it could be re-enabled with correct values (no negative signs). Somebody else previously asked here but then stopped responding before it was completely resolved.
Experiment 1 (MutationObserver)
Have seen some suggestions to use a MutationObserver, but I'm fairly new to Javascript so would appreciate any help - this is the code I've compiled (based on the Mozilla explanations of MutationObservers):
// Select the node that will be observed for mutations
const targetNode = document.getElementById(this.questionId + "~1~toolTipBox");
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true, characterData: true };
// Create a new instance of `MutationObserver` named `observer`,
const observer = new MutationObserver(function() {
targetNode.innerHTML = targetNode.innerHTML.replace("-", "");
});
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
It doesn't work and just freezes the webpage (probably because it seems to be self-referring) but I can't think of another way to observe the change and then apply the change to that part!
Experiment 2 (onmousemove)
(Here's another experiment I did which doesn't seem to work either, based on whenever the slider handle is moved - the main problem seems to be actually changing the text within the toolTipBox - if anybody has any suggestions on how to edit the text inside the toolTipBox that would be very helpful!):
var QIDtoolTip = this.questionId + "~1~toolTipBox"
//var QIDtrack = this.questionId + "~1~track"
//function which SHOULD update the numbers to remove negatives
function updateThings() {
document.getElementById(QIDtoolTip).innerHTML.replace("-","");
//document.getElementById(QIDtrack).attr(aria-valuenow, ***SOMEWAYOFREMOVINGMINUSSIGNS);
//document.getElementById(QIDtrack).attr(aria-valuetext, ***SOMEWAYOFREMOVINGMINUSSIGNS);
}
document.getElementById(this.questionId+"~1~handle").onmousemove = updateThings;