const visited = ["- Visit my new blog post #3 -"]; // remove and uncomment next two lines
// const saved = localStorage.getItem("visited");
// const visited = saved ? JSON.parse(saved) : []; // restore what was visited here.
document.querySelectorAll("a.button").forEach(a => {
if (visited.includes(a.textContent)) a.classList.remove("badge")
})
document.addEventListener("click",function(e) {
const tgt = e.target;
if (tgt.classList.contains("badge")) {
const text = tgt.textContent;
if (!visited.includes(text)) {
visited.push(text);
tgt.classList.remove("badge")
// localStorage.setItem("visited",JSON.stringify(visited)); // uncomment
}
}
})
a { text-decoration:none }
.button {
background: linear-gradient(to bottom, rgba(37,130,188,1) 0%,rgba(41,137,216,1) 32%,rgba(41,137,216,1) 42%,rgba(175,224,234,1) 100%);
width: 60px;
height: 60px;
border-radius: 10px;
border: none;
margin-top: 40px;
margin-left: 40px;
position: relative;
box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}
.button.badge:before {
content: "!";
width: 18px;
height: 18px;
line-height: 18px;
text-align: center;
display: block;
border-radius: 50%;
background: rgb(67, 151, 232);
border: 1px solid #FFF;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
color: #FFF;
position: absolute;
top: -7px;
left: -7px;
}
.button.badge.top-right:before {
left: auto;
right: -7px;
}
.button.badge.bottom-right:before {
left: auto;
top: auto;
right: -7px;
bottom: -7px;
}
.button.badge.bottom-left:before {
top: auto;
bottom: -7px;
}
<a href="#" class="button badge">- Visit my new blog post #1 - </a><hr/>
<a href="#" class="button badge top-right">- Visit my new blog post #2 - </a><hr/>
<a href="#" class="button badge bottom-right">- Visit my new blog post #3 -</a><hr/>
<a href="#" class="button badge bottom-left">- Visit my new blog post #4 -</a>