[英]How do I change the background of my body when picking a color from my input with the type=“color”
[英]How do I take color Input from users and change color of WIX elements accordingly?
這是我到目前為止一直在應用的代碼,但它不起作用。
$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';
});
我們在您的問題中遺漏了一些大局,但無論如何我都會盡力回答。
在您的onClick
中,您將背景顏色設置為文字字符串。 那不是你想要的。 你可能想做更多這樣的事情:
bigBox.style.backgroundColor = $w('#colorInput').value;
bigBox.style.borderColor = $w('#colorInput').value;
當然,您依賴於人們輸入有效的顏色名稱。 您可能需要考慮使用下拉菜單或類似的東西,而不是開放式文本輸入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.