Crash Override
Crash Override

Reputation: 1427

Setting background color when user clicks, changing back when user clicks anywhere else

I have come across a situation where I want to set the background color of a list item <li> tag when the user clicks on that item. I want it to remain that background color forever until the user clicks elsewhere on the page except another <li> tag.

In Meteor, I know how to use a mousedown or click event on the <li> tag to set the background color of itself, but how can set a Meteor click event on everything else that can reset the background color of that <li>?

I am using Meteor, Javascript, and Materialize CSS.

Upvotes: 1

Views: 96

Answers (1)

SharpEdge
SharpEdge

Reputation: 1762

Just add a click event listener on the body and check that target is different from your li

Upvotes: 2

Related Questions