A jQuery plugin that sets an attribute or adds a class to a previously visited link on the same domain.
This repository has been archived on 2025-09-02. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
2016-05-06 16:23:26 -05:00
dist generate dist. 2016-05-06 16:23:26 -05:00
src Allow for classes. 2016-05-06 15:58:09 -05:00
.gitignore Initial commit 2016-05-03 15:41:41 -05:00
bower.json Updated bower.json 2016-05-03 18:57:35 -05:00
Gruntfile.js Initial commit 2016-05-03 15:41:41 -05:00
LICENSE Initial commit 2016-05-03 15:41:41 -05:00
package.json Initial commit 2016-05-03 15:41:41 -05:00
README.md Updated readme documentation. 2016-05-06 16:05:59 -05:00

jquery-visited

A jQuery plugin that allows you to do more interesting :visited styling for hyperlinks. Because bad apples blew it for us.

Inspired by and reimplemented in jQuery from Joel Califa's blog post here: http://joelcalifa.com/blog/revisiting-visited/.

Just Show Me The Demo

Here you go, buddy: https://ardouglass.github.io/jquery-visited/

Download

Run one of these commands in your bash according to your needs.

git clone https://github.com/ardouglass/jquery-visited.git

bower install jquery-visited

npm install jquery-visited

Getting Started

The code below is a before/after example.

<!-- Before running -->
<div class="items">
  <a href="/stuff">Stuff</a>
  <a href="/more-stuff">More Stuff</a>
  <a href="/the-best-stuff">The Best Stuff</a>
</div>

<!-- Example call to .visited() -->
<script type="text/javascript" src="jquery.visited.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $('.items a').visited('visited-link');
    // with no args, it will apply data-visited='true' instead of adding a css class
  });
</script>

<!-- After running, assuming you've visited /stuff since jquery.visited.js was included -->
<div class="items">
  <a href="/stuff" class="visited-link">Stuff</a>
  <a href="/more-stuff">More Stuff</a>
  <a href="/the-best-stuff">The Best Stuff</a>
</div>

<!-- Why this is useful: modify things not allowed by :visited -->
<style type="text/css">
  a.visited-link {
    background-image: url('some-image.png');
  }

  a.visited-link:after {
    content: 'You already saw this one';
  }
</style>