Skip to main content
1-Visitor
April 1, 2020
Solved

Changing the background colour of a menu item after click.

  • April 1, 2020
  • 1 reply
  • 3967 views

I would like to change the background colour of the side menu items after I've clicked them.  The screenshot below shows the colour I would like to change.

 

Is it pseudo element or class that I need to apply CSS?

Best answer by sebben

Hi,

 

you can change this color by changing the .item.activated class:

 

For example:

.item.activated {
background-color: red;
}

 

1 reply

14-Alexandrite
April 2, 2020

Hi,

you can define a function in your javascript like this:

$scope.changeBackground= function(){
document.querySelector('.simple-label').style.background = 'rgba(255, 255, 255, 1)';
}

You can call the function from your label's click event. The label needs to have the class 'simple-label' in that case.

micah1-VisitorAuthor
1-Visitor
April 2, 2020

The menu was created by adding another view. It doesn't appear in the tree, so I'm unable to add a class or click event to it.

14-Alexandrite
April 3, 2020

I'm not sure if I understand you right...

But you should be able to see the tree of the added view when you click on the view first.

Can you add screenshot of you studio editor or even better the project? Then we can figure it out for sure.

 

Thanks.