0
I wanted to make a Javascript if repeated in other screen components, in this example I am passing I did a foreach and inside it I put my javascript. the intention is that it repeated itself 10 times, but it only works once. Is there something similar to what I’m trying to do? the intention is that the Ids were varied at each foreach, but I put the +i or not it always runs in a single div.
@for (var i = 10; i < 21; i++)
{
<p>A script on this page starts this clock:</p>
<p id="demo+@i"></p>
<script>
var myVar = setInterval(myTimer, 1000);
function myTimer() {
var d = new Date();
document.getElementById("demo"+@i).innerHTML = d.toLocaleTimeString();
}
</script>
}
Boy, thank you very much, that’s exactly what I was trying to understand, it will help me a lot. thanks
– Fabio Souza