This is the code i've been applying so far which is not working.
$w.onReady(function () {
const bigBox = $w('#box0');
const firstCircle = $w('#box1');
const secondCircle = $w('#box2');
const thirdCircle = $w('#box3');
const fourthCircle = $w('#box4');
const fifthCircle = $w('#box5');
const changeBoxBtn = $w('#changeBox');
const colorInput = $w('#input2') ;
changeBoxBtn.onClick(event => {
bigBox.style.backgroundColor = 'colorInput';
bigBox.style.borderColor = 'colorInput';
});
We're missing a bit of the big picture in your question, but I'll try my hand at answering anyway.
In your onClick
you are setting the background color to a literal string. That's not what you want. You probably want to do something more like this:
bigBox.style.backgroundColor = $w('#colorInput').value;
bigBox.style.borderColor = $w('#colorInput').value;
Of course, you are relying on people to input valid color names. You might want to consider using a dropdown or something similar instead of an open ended text input.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.