Update Text to Display a Variable

Hello, I have a variable that is incremented by 2 buttons on my page, and I would like a textbox to display the current value of this variable. See my code below, the buttons are incrementing the variable properly (I have checked via console.log(count)), but the textbox will not update to reflect the variable. Am I referencing something incorrectly? Thank you in advanced for your help.

Script:
var count = 1;
var display = $(‘div.widget-text-v3[data-id=“6331e4ecb480dd0037cbabb2”]’).find(‘span’);

$(‘div.common-button[data-id=“63350a1edb630c0013f9aff0”]’).click(add);
$(‘div.common-button[data-id=“63350acfb22db0003bc22f82”]’).click(subtract);

function add() {
count++;
display.text(count);
};

function subtract() {
if (count > 1) {
count–;
}
};

I solved this by manually creating a textbox in the code widget, and then passing the variable into my manually created textbox via “innerHTML”.

1 Like