I've got a page with a whole bunch of links to NPC characters in a web game. You can battle each of them twice per day. What I'm hoping for is a way to have the links show in blue when a user first visits the page. The first click of any of the links will turn it orange. The second click will turn the link red. If they refresh the page of course all the links will go back to blue. I feel like the page I have should work but, of course it sin't so I'm seeking help from the AWESOME stackoverflow group :-)
here is what I have so far:
$("a").on("click", function() {
if ($(this).hasclass("fresh")) {
$(this).removeClass("fresh").addClass("clickedonce");
}
if ($(this).hasclass("clickedonce")) {
$(this).removeClass("clickedonce").addClass("clickedtwice");
}
});
body {
background-image: url(https://fe623c4c56cb423a1796-41d97e3e92b81615c7f3767eb26dcf89.ssl.cf2.rackcdn.com/city/brickbg1.png);
background-repeat: repeat;
background-attachment: fixed;
background-position: top;
}
.column {
float: left;
width: 50%;
}
.row:after {
content: "";
display: table;
clear: both;
}
.fresh {
color: blue;
}
.clickedonce {
color: orange;
}
.clickedtwice {
color: red;
}
```
<html>
<head>
<title="FJ's quick NPC Links"></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div class="row">
<div class="column">
<p>NPC Lookup Links</p>
<a target="_blank" class="fresh" href="https://www.heroesrisinggame.com/game/profile.game?user_id=1002"> lev01 Raptor</a><br>
<a target="_blank" class="fresh" href="https://www.heroesrisinggame.com/game/profile.game?user_id=1009"> lev03 Graggleback from Dimension Z</a><br>
<a target="_blank" class="fresh" href="https://www.heroesrisinggame.com/game/profile.game?user_id=1020"> lev04 Firebrand</a><br>
</div>
</div>
</body>
</html>