i am trying to change a variable in a nested function, it's a lot of code so here is a simplified build up of the JS file
var time = 0;
$("button").click(function(){
time = time + 1
});
function thisIsTheTime(){
clockDesign()
// big bunch of variables and more code
}
function clockDesign(){
ProgressIndicator: {
name: "ProgressIndicator",
element: create_element_with_attributes("div", {
innerHTML:
"<div class='ProgressbarContainer' style='text-align: center;'>
+ time
+ </div>"
})
}
}
what i try to achieve is the following, update the time - each time a person clicks the button - in the second function ClockDesign() However this is rendered directly when the page loads. it keeps the 0.
var timeoutside those functions, so you can access and modifytimefrom anywhere. Please post valid code that reproduces the problem, a minimal reproducible example. I suspect the problem here is that you expect the progress to magically update because you've changed the value oftime; that's not going to happen. You have to manually update the HTML yourself.