Mark link as "read"


I have a listing website which lists contests. What I am wanting to do is to have a link that says “Entered?” and then when the user clicks on it, it will show “Entered” or a check icon.

I am guessing this will have to be done based on cookies?

What would be the best way to achieve this?


How about using a:visited?

I was thinking the same thing, but apparently you can’t add generated content to a visited link (source:

I can’t find a workaround for this specific use case (though I’m sure there is one), but you could add an event listener to your links which tracks which links were selected, but that would only capture those links visited during that site visit - it wouldn’t track the ones visited from a previous session.

Thanks for the replies. I’m ideally after something that would remain if the user leaves and then re-visits the website which was why I thought cookies would be needed.



Thanks for the reply.

I have put this together, but I don’t think I have the above localStorage part right.

You’ll need to check for the value in storage when a visitor lands on your page and adjust things accordingly.

A bit like what I’m doing here.

1 Like

More like exactly what you’re doing with your check all button :wink:

@ James_Hibbard 0 Thank you very much! That worked great!

Am I right in thinking the localStorage will only get wiped when browser history/cache is cleared?

Thanks again :smiley:

Sorry, I have a question.

If I use the <div id="checkbox-container"> and the checkboxes with the same ID on other pages, will the checkboxes still be “remembered” ?

Yeah. Or when you expire it (which would rely on the user revisiting your page).

Depends how you set things up. If you have no JavaScript saving things to local storage on the other pages, then it doesn’t matter what the IDs are.

If you have a specific question, make a minimal runnable demo and I’ll be happy to take a look.

1 Like

Thanks for the reply.

How would I go about setting the expiry date? Ideally I would like it to never expire.

Then you don’t need to do anything and the only time it shall expire is when the user clears their browser cache.

1 Like

Great, thanks for your help and the great tutorial :slight_smile:

1 Like

Just an update on having the code on other pages -it does update other pages, so its all good :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.