Skip to content

Instantly share code, notes, and snippets.

@abrarShariar
Forked from c-kick/hnl.taphover.js
Created February 27, 2016 06:44
Show Gist options
  • Select an option

  • Save abrarShariar/533839eee31c185283f4 to your computer and use it in GitHub Desktop.

Select an option

Save abrarShariar/533839eee31c185283f4 to your computer and use it in GitHub Desktop.

Revisions

  1. @c-kick c-kick created this gist Nov 17, 2014.
    14 changes: 14 additions & 0 deletions hnl.taphover.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    //taphover - a solution to the lack of hover on touch devices.
    //more info: http://www.hnldesign.nl/work/code/mouseover-hover-on-touch-devices-using-jquery/
    $('a.taphover').on('touchstart', function (e) {
    'use strict'; //satisfy the code inspectors
    var link = $(this); //preselect the link
    if (link.hasClass('hover')) {
    return true;
    } else {
    link.addClass('hover');
    $('a.taphover').not(this).removeClass('hover');
    e.preventDefault();
    return false; //extra, and to make sure the function has consistent return points
    }
    });