I need to dynamically change the background color of a tag in my code based on the URL. If the URL contains Suisse, I want the background color of the tag #switch-univers li a.bilgroup
to be green.
JS
if (window.location.href.indexOf("Suisse") > -1) {
$('#switch-univers li a.bilgroup').css({ backgroundColor, 'green' });
} else if (window.location.href.indexOf("Sales") > -1) {
$('#switch-univers li a.sales').css({ backgroundColor, 'blue' });
} else if (window.location.href.indexOf("My%20desktop") > -1) {
$('#switch-univers li a.lifebil').css({ backgroundColor, 'pink' });
}
Here is my HTML:
<body>
<Div id= « switch-univers » >
<li><a class=“bilgroup“>Suisse</a></li>
<li><a class=“sales“>Sales</a></li>
<li><a class=“lifebil“>My desktop</a>
</li>
</div>
</body>
However, nothing seems to be happening... Any suggestions?