# Code to invert text colour in header elements

**URL:** <https://forum.wixstudio.com/t/code-to-invert-text-colour-in-header-elements/54421>\
**Category:** Ask the community\
**Tags:** code, wix-studio, question\
**Created:** [December 7, 2023, 9:07am UTC](https://forum.wixstudio.com/t/code-to-invert-text-colour-in-header-elements/54421 "2023-12-07T09:07:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adriana\_Navia](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adriana_navia/32/84968_2.png) [@Adriana\_Navia](https://forum.wixstudio.com/u/Adriana_Navia)\
**Post date:** [December 7, 2023, 9:07am UTC](https://forum.wixstudio.com/t/code-to-invert-text-colour-in-header-elements/54421/1 "2023-12-07T09:07:00Z")

</div>

**Question:**  
Wanting to get some code so the elements within my header change colour to black. Initially my header is transparent with White text within the elements and I am looking for this to change to black when it scrolls or is highlighted. i.e the header goes white and the text goes black.

**Product:**  
Wix Studio

**What are you trying to achieve:**  
As above

**What have you already tried:**  
Tried using chatgpt to help me write code and tried searching but was not able to get anything to work.

**Additional information:**  
Here is a website I have seen which is doing exactly what I want: [APM Monaco™ | Fashion & Luxury Jewelry from Monaco](https://www.apm.mc/?currency=AUD)

---

<div class="post-metadata">

**Author:** ![Dan\_Suhr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dan_suhr/32/94074_2.png) [@Dan\_Suhr](https://forum.wixstudio.com/u/Dan_Suhr)\
**Post date:** [December 8, 2023, 2:11am UTC](https://forum.wixstudio.com/t/code-to-invert-text-colour-in-header-elements/54421/2 "2023-12-08T02:11:16Z")

</div>

[https://dcidesigns.wixstudio.io/my-site-25](https://dcidesigns.wixstudio.io/my-site-25)

```javascript
$w.onReady(function () {
    // When the page scrolls back up and the section leaves the viewport
    $w("#section5").onViewportLeave(() => {
        $w("#text6").hide(); // Hide text6
        $w("#text5").show(); // Show text5
    });

    // When the page scrolls and the section below enters the viewport
    $w("#section5").onViewportEnter(() => {
        $w("#text6").show(); // Show text6
        $w("#text5").hide(); // Hide text5
    });
});

```
