I have an 'h1' tag that i need to add a class to change its colour based on the url parameter. I have two parameters that are passed so depending on which one a different class is added.
I have seen a previous post by @Matt Martin with an answer by @Florian Margaine which uses Switch statements which looks like a nice method, nut i cannot seem to get it to work.
I have tried the following with no success:
HTML:
<h1 id="head" class="page-head">About Right to Manage for</h1>
jQuery:
$(function() {
switch (window.location.pathname) {
case '?type=private':
$('#head').addClass('private')
case '?type=retirement':
$('#head').addClass('retirement')
}
});
so I would have either of the following:
<h1 id="head" class="page-head private">About Right to Manage for</h1>
or
<h1 id="head" class="page-head retirement">About Right to Manage for</h1>
pathnamemeans, then log it to console or go read up on it.window.location.searchinstead