Git Product home page Git Product logo

jquery-hoverable's Introduction

jQuery Hoverable

Author

Sébastien Lavoie ([email protected])

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

jquery-hoverable's People

Contributors

lavoiesl avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

lemoinem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.