this might be a coding/velo question, but I’m looking to have my site change background colors with a button click. pretty simple but I’m not sure how to do this https://www.paulineesguerra.com/
Hi
You can change background color of not all elements.
You can find here what elements are available for changing their background color - https://www.wix.com/velo/reference/$w/style/backgroundcolor
The code is simple
$w.onReady(function () {
$w('#button1').onClick( () => {
$w('#button1').style.backgroundColor = 'red'
})
});
so that worked for buttons, but all i want to do is have a button click so that it changes the background of the page. see here - https://www.paulineesguerra.com/. i just want the user to be able to click the box red and the site background changes red on click.
@paulineesg1 You can’t change the background of the whole page using Velo. If you visit the article I’d sent you before you will see the list of editor elements, available for changing the background. Velo has no direct access to DOM, so you can affect only some of editor elements.
However, this task can be done with custom element, but this implementation is more difficult to do. Using custom element you can do anything you want.