# Button color-change-problem...

**URL:** <https://forum.wixstudio.com/t/button-color-change-problem/2298>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [February 5, 2021, 12:16pm UTC](https://forum.wixstudio.com/t/button-color-change-problem/2298 "2021-02-05T12:16:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [February 5, 2021, 12:16pm UTC](https://forum.wixstudio.com/t/button-color-change-problem/2298/1 "2021-02-05T12:16:57Z")

</div>

Found a strange behaviour of button-background color.

All i wanted to achieve is to let the button change it’s color onMouseIn(), but the color do not change on mouse in, instead the color changes when you leave the button —\> onMouseOut().

Opacity of border & button was set to 100% .

What’s the problem?

This was the used very simple code…

```javascript
export function button560_mouseIn(event) {
    $w('#button560').style.backgroundColor="red" 
}

```

Instead of taking the color from CODE, it takes the predifined color of the wix-UI-settings.

Why?

---

<div class="post-metadata">

**Author:** ![volkaertskristof](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/volkaertskristof/32/18158_2.png) [@volkaertskristof](https://forum.wixstudio.com/u/volkaertskristof)\
**Post date:** [February 5, 2021, 1:20pm UTC](https://forum.wixstudio.com/t/button-color-change-problem/2298/2 "2021-02-05T13:20:14Z")

</div>

If you move over it and stay on it it wil turn red when on it.  
it has a delay.  
so i gues there is the problem.  
if i do it and stay on it it turns red.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [February 5, 2021, 6:57pm UTC](https://forum.wixstudio.com/t/button-color-change-problem/2298/3 "2021-02-05T18:57:47Z")

</div>

Ok, i will check it later. How long is the mentioned delay? 5secs?  
That can’t be the right way. It hast to be fixed!  
A mouseIn with such an delay, thats no longer the right button-behaviour.  
Was it always like that? Did this delay already exists for a longer period of time?

---

<div class="post-metadata">

**Author:** ![volkaertskristof](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/volkaertskristof/32/18158_2.png) [@volkaertskristof](https://forum.wixstudio.com/u/volkaertskristof)\
**Post date:** [February 5, 2021, 10:41pm UTC](https://forum.wixstudio.com/t/button-color-change-problem/2298/4 "2021-02-05T22:41:05Z")

</div>

I mever tried it before so i don’t know how long it whas before

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [February 5, 2021, 11:20pm UTC](https://forum.wixstudio.com/t/button-color-change-problem/2298/5 "2021-02-05T23:20:55Z")

</div>

@volkaertskristof I tested it with my button, and the behaviour is not the same as you described.

When i hover over the button (which should get —\> “red” on hovering), instead nothing happens and the color of the predefined “wix-UI” is shown.

I can even hold on it 20min. and the color do not change, like it should do on → onMouseIn().

Here the example… [https://www.media-junkie.com/blank-2](https://www.media-junkie.com/blank-2)

```javascript
$w.onReady(function () { });

export function myButton_mouseIn(event) {$w('#myButton').style.backgroundColor="red"}

```

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [February 7, 2021, 5:02pm UTC](https://forum.wixstudio.com/t/button-color-change-problem/2298/6 "2021-02-07T17:02:20Z")

</div>

Who can give some light into the dark here ?  
Or is it just working wrong for me ?  
What i see is —\> onMouseIn → color = NOT-RED !  
Even if you hold 24-hours, nothing happens.  
The color changes first time —\> onMouseOut → RED!
