i want to use a variable in #id
e.g.
if (wixWindow.formFactor === "Mobile"){
let total = 6;
for (let i = 1; i < total; i++){
total = i;
$w("#group +{total}+ ").show();
if (i === 6 ){
i = 1;
}}}
*** And if someone can help me understand how set time to loop !
Thanks ! i got it, theres the code :
if (wixWindow.formFactor === "Mobile"){ var i = 2; function myLoop () { setTimeout(function () { $w("#group1").hide(); $w("#group2").hide(); $w("#group3").hide(); $w("#group4").hide(); $w("#group5").hide(); $w("#group6").hide(); $w("#group7").hide(); if (i === 8){ i = 2; } $w(`#group${i}`).show(); i++; if (i <= 8) { myLoop(); } }, 3000); } myLoop(); }
Hi Daniel,
You can use the setTimeOut function for that purpose.
Best,
Tal.
i meant time to do a loop, for example every 4 second it would loop once.
if (wixWindow.formFactor === "Mobile") { let total = 6; for (let i = 1; i < total; i++) { total = i; $w(`#group${total}`).show(); if (i === 6) { i = 1; } },4000 }
Hi,
You need to use backticks: `${variableName}`. I've corrected the code for you:
if (wixWindow.formFactor === "Mobile"){ let total = 6; for (let i = 1; i < total; i++){ total = i; $w(`#group${total}`).show(); if (i === 6 ){ i = 1; } } }
As for your second query, I'm not sure that I fully understand what you were referring. Can you please clarify what is the scenario?
Thanks,
Tal.