top of page
This site was designed with the
.com
website builder. Create your website today.
Start Now
Change color
//Code using predefined colors $w.onReady(function () { var arr = ['red', 'blue' , 'yellow' , 'green']; let i = 0; $w('#button1').onClick(() => { if(i >= arr.length) { i = 0 $w('#box4').style.backgroundColor = arr[i] } else { $w('#box4').style.backgroundColor = arr[i] } i++ }) });
Red 10
Blue10
Green 10
// Using RGB $w.onReady(function () { let debouncer; for(let j=1 ; j<4 ; j++) { $w(`#slider${j}`).onChange(() =>{ slider() }) } }); function slider () { let red = $w('#slider1').value; let blue = $w('#slider2').value; let green = $w('#slider3').value; $w('#box5').style.backgroundColor = `rgb(${red} , ${green} , ${blue})` }
bottom of page