Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
/ jQuery-Hoverable Public archive

jQuery plugin that adds and removes a class to toggle hovered state

Notifications You must be signed in to change notification settings

lavoiesl/jQuery-Hoverable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery Hoverable

Author

Sébastien Lavoie (github@lavoie.sl)

Description

Simple solution to a common problem in IE6 that doesn’t support :hover for other elements than anchors:

  • Adds classes hoverable-{over,out} on the wrapper
  • Fires events

Prerequisites

  • jQuery, should work with any version but tested with 1.7

Basic setup

  <div class="hoverable">
    <h4>Title</h4>
    <ul>
        <li>Test</li>
        <li>Test</li>
        <li>Test</li>
        <li>Test</li>
    </ul>
  </div>

Initialization

$(function() {
    $('.hoverable').hoverable();
});

Options

{
    overEvent: 'mouseenter',               // jQuery event to register on
    outEvent: 'mouseleave',                 // Idem
    overClass: 'hoverable-over',          // Class to be added when the item is hovered
    outClass: 'hoverable-out'             // Idem
}

CSS Example

.hoverable ul {
  display:none;
}
.hoverable-over ul {
  display: block;
}

Events

Two events are made and they both pass the data.show as a boolean

  • hoverable.over
  • hoverable.out
$('.hoverable').on('hoverable.over', function(event){
  console.log("Hoverable is hovered");
});
$('.hoverable').on('hoverable.out', function(event,data){
  console.log("Hoverable is not longer hovered");
});

Demo

Checkout the demo

About

jQuery plugin that adds and removes a class to toggle hovered state

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published