{"id":22423305,"url":"https://github.com/prantlf/jquery.mousehover","last_synced_at":"2025-07-28T07:07:01.617Z","repository":{"id":57282598,"uuid":"89137619","full_name":"prantlf/jquery.mousehover","owner":"prantlf","description":"Executes event handlers, when the *real* mouse pointer hovers over the selected elements. Ignores the emulated tap-hover event.","archived":false,"fork":false,"pushed_at":"2019-09-24T07:36:09.000Z","size":133,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-08T02:19:36.796Z","etag":null,"topics":["hover","jquery-plugin","mouse-events"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prantlf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-23T11:43:01.000Z","updated_at":"2019-09-24T07:34:42.000Z","dependencies_parsed_at":"2022-08-31T09:20:21.183Z","dependency_job_id":null,"html_url":"https://github.com/prantlf/jquery.mousehover","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/prantlf/jquery.mousehover","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fjquery.mousehover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fjquery.mousehover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fjquery.mousehover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fjquery.mousehover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prantlf","download_url":"https://codeload.github.com/prantlf/jquery.mousehover/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fjquery.mousehover/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267327534,"owners_count":24069442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hover","jquery-plugin","mouse-events"],"created_at":"2024-12-05T18:09:57.719Z","updated_at":"2025-07-28T07:07:01.597Z","avatar_url":"https://github.com/prantlf.png","language":"JavaScript","readme":"# jquery.mousehover\n[![NPM version](https://badge.fury.io/js/jquery.mousehover.png)](http://badge.fury.io/js/jquery.mousehover)\n![Bower version](https://img.shields.io/bower/v/jquery.mousehover.svg)\n[![Size](http://img.badgesize.io/prantlf/jquery.mousehover/master/jquery.mousehover.min.js?compression=gzip\u0026color=blue)](https://raw2.github.com/prantlf/jquery.mousehover/master/jquery.mousehover.min.js)\n[![Build Status](https://travis-ci.org/prantlf/jquery.mousehover.png)](https://travis-ci.org/prantlf/jquery.mousehover)\n[![Dependency Status](https://david-dm.org/prantlf/jquery.mousehover.svg)](https://david-dm.org/prantlf/jquery.mousehover)\n[![devDependency Status](https://david-dm.org/prantlf/jquery.mousehover/dev-status.svg)](https://david-dm.org/prantlf/jquery.mousehover#info=devDependencies)\n[![Code Climate](https://codeclimate.com/github/prantlf/jquery.mousehover/badges/gpa.svg)](https://codeclimate.com/github/prantlf/jquery.mousehover)\n[![Codacy Badge](https://www.codacy.com/project/badge/f3896e8dfa5342b8add12d50390edfcd)](https://www.codacy.com/public/prantlf/jquery.mousehover)\n\n[![NPM Downloads](https://nodei.co/npm/jquery.mousehover.png?downloads=true\u0026stars=true)](https://www.npmjs.com/package/jquery.mousehover)\n\nThis event-subscribing jQuery plugin behaves like [`jQuery.hover`], as long\nas the *real* mouse is used. If the `mouseenter` and `mouseleave` events are\nemulated by other input device, `jQuery.mousehover` does not trigger the\nevent handlers.\n\n* [Motivation](#motivation)\n* [Synopsis](#synopsis)\n  + [Parameters](#parameters)\n  + [Methods](#methods)\n  + [Options](#options)\n* [Usage](#usage)\n* [Example](#example)\n* [Installation](#installation)\n* [Build](#build)\n* [Contributing](#contributing)\n* [Release History](#release-history)\n* [License](#license)\n\n## Motivation\n\nAlthough mobile devices do not support mouse as an input device, they trigger\nmouse-specific events, when your finger touches the display. These emulated\nevents include `mouseenter` and `mouseleave`, which trigger event handlers\nregistered by `jQuery.hover`. It may not be a problem, if you follow the best\npractice and do not use JavaScript hover handling at all, or perform visual\nenhancements only inside the event handlers. Otherwise you will face:\n\n* [Double-tap issue](https://css-tricks.com/annoying-mobile-double-tap-link-issue/)\n  caused by having the first tap act as `hover` and the second one as `click`.\n* Showing call-outs, context menus, toolbars or other interactive controls\n  on touch and not being able to get rid of them easily. Not all devices fire\n  `mouseleave` after `mouseenter` and end the chain of events with `click`.\n\nIf you write an interface for devices capable of using multiple input devices\nlike mouse, pen and touch, and you need to ensure, that part of that interface\nwill work only if the input device is a *real* mouse, the plain `jQuery.hover`\nhandler will not be enough. The `jQuery.mousehover` plugin allows you for safe\nmouse event listening, without you coding the *real* mouse detection.\n\n## Synopsis\n\n```javascript\n$(selector).mousehover(handlerIn, handlerOut, options);\n$(selector).mousehover('off', options);\n```\n\nBinds one or two handlers to the selected elements, which will be executed,\nwhen the *real* mouse pointer enters and leaves the elements. Ignores the\nemulated hover effect caused by tapping on a touch display. It calls\n[`jQuery.on`] for selected events needed for the reliable operation.\n\nSee the original documentation for [`jQuery.hover`] for more information.\n\n### Parameters\n\n| Name       | Type                    | Description                                                               |\n| ---------- | ----------------------- | ------------------------------------------------------------------------- |\n| handlerIn  | Function([Event] event) | A function to execute when the mouse pointer enters the selected element. |\n| handlerOut | Function([Event] event) | A function to execute when the mouse pointer leaves the selected element. |\n| options    | [Object]                | An object with extra parameters for the plugin or its method execution.   |\n\nThe parameter `handlerIn` has to be provided, if you are not unregistering the\nevent handlers by passing the methof name `off` instead of it. The parameter\n`handlerOut` is optional; if not provided, the event handler `handlerIn` will\nbe used instead of it. The `options` parameter is optional.\n\nExcept for pasing the parameters as a list to the plugin function, you can\npass them to it as an object literal too.\n\n```javascript\n$(selector).mousehover({\n  handlerIn: handlerIn,\n  handlerOut: handlerOut,\n  options: {\n    namespace: 'menu'\n  }\n});\n```\n\n### Methods\n\n#### noConflict() : jQuery.mousehover\n\nRestores the earlier mousehover plugin, which had been registered in jQuery\nbefore this one. This plugin is returned for explicit usage.\n\n```javascript\nvar mousehover = $.fn.mousehover.noConflict();\nmousehover.call($(selector), handlerIn, handlerOut, options);\n```\n\n#### off : jQuery\n\nUnsubscribes event handlers registered by the previous call to `mousehover`.\nIt calls [`jQuery.off`] for the events used during the registration time.\n\n```javascript\n$(selector).mousehover('off', options);\n```\n\n### Options\n\n#### namespace : string\n\nRegisters event handlers for `mousehover` using the specified namespace. If\nother code registers `mouseenter`, `mouseleave`, `touchend`, `pointerenter`\nand `pointerleave` events, namespacing allows for selective unregistration\nof the particular event handlers. If you want to make sure, that you do not\naffect other plugins, you should use a unique namespace for `mousehover`.\nNo namespace is used by default.\n\n```javascript\n$(selector).mousehover(handlerIn, handlerOut, {namespace: 'menu'});\n$(selector).mousehover('off', {namespace: 'menu'});\n```\n\n## Usage\n\nYou have to ensure, that `jQuery` is included earlier, than\n`jquery.mousehover.js`. The slim version of jQuery is enough.\n\n```html\n\u003cscript src=\"https://code.jquery.com/jquery-3.2.1.slim.min.js\"\n        integrity=\"sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN\"\n        crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n\u003cscript src=\"jquery.mousehover.min.js\"\n        integrity=\"sha384-SQjNFjqu6aB5MdZehH5H2s+HipiAfjmg6BCwBESCcxoACk1XN8j8UAzbrGL8M64J\"\n        crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n```\n\nIf you use [RequireJS] or other [AMD] module loader, you have to ensure, that\nthe `jquery` module is mapped correctly. The `jquery.mousehover` module will\nload the `jquery` module as its dependency automatically.\n\n```html\n\u003cscript\u003e\nrequire.config({\n  paths: {\n    jquery: 'https://code.jquery.com/jquery-3.2.1.slim.min.js'\n  }\n});\nrequire('jquery', 'jquery.mousehover', function ($) {\n});\n\u003c/script\u003e\n```\n\nIf you use [CommonJS] and compile your project to be loadable in the web\nbrowser or other [AMD] module loader, you can install `jquery` and\n`jquery.mousehover` as `NPM` or `Bower` modules.\n\n```javascript\nvar $ = require('jquery');\nrequire('jquery.mousehover');\n\u003c/script\u003e\n```\n\n## Example\n\nInsert the text \"\u003e\u003e\" before the list item, which the mouse pointer is\nhovering above, and remove the text, as soon as the mouse pointer leaves\nthe list item:\n\n```html\n\u003cul\u003e\n  \u003cli\u003eApple\u003c/li\u003e\n  \u003cli\u003eOrange\u003c/li\u003e\n\u003c/ul\u003e\n\u003cscript\u003e\n  $('li').mousehover(\n    function () {\n      $(this).prepend($('\u003cspan\u003e\u0026gt;\u0026gt; \u003c/span\u003e'));\n    },\n    function () {\n      $(this).find('span:first').remove();\n    }\n  );\n\u003c/script\u003e\n```\n\n## Installation\n\nMake sure that you have [NodeJS] \u003e= 6 installed. You can use either `npm`\nor `bower` to install this package and its dependencies.\n\nWith [NPM]:\n\n```shell\nnpm install jquery.mousehover\n```\n\nWith [Bower]:\n\n```shell\nbower install jquery.mousehover\n```\n\n## Build\n\nMake sure that you have [NodeJS] \u003e= 6 installed. Clone the Github\nrepository to a local directory, enter it and install the package\ndependencies (including the development dependencies) by `npm`:\n\n```shell\ngit clone https://github.com/prantlf/jquery.mousehover.git\ncd jquery.mousehover\nnpm install\n```\n\nExamples and tests will be functional now.\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding\nstyle. Add unit tests for any new or changed functionality.\n\nFirst fork this repository and clone your fork locally instead of cloning\nthe original. See the \"Build\" chapter above for more details about how to\nclone it and install the build dependencies.\n\nBefore you commit, update minified files and source maps, re-generate\ndocumentation and check if tests succeed:\n\n```shell\nnpm run build\nnpm test\n```\n\nCommit your changes to a separtate branch, so that you can create a pull\nrequest for it:\n\n```shell\ngit checkout -b \u003cbranch name\u003e\ngit commit -a\ngit push origin \u003cbranch name\u003e\n```\n\n## Release History\n\n * 2018-04-27   v1.0.0   Dropped support of Node.js 4\n * 2014-04-28   v0.2.1   Fix detection of pointer and touch events \n                         in the browser, fix detection of mouse event type\n * 2014-04-25   v0.2.0   Add noConflict method, off method for unregistering\n                         event handlers and optional event namespacing\n * 2014-04-24   v0.1.0   Initial release\n\n## License\n\nCopyright (c) 2017-2019 Ferdinand Prantl\n\nLicensed under the MIT license.\n\n[Bower]: http://bower.io/\n[NodeJS]: http://nodejs.org/\n[NPM]: https://www.npmjs.com/\n[`jQuery.hover`]: https://api.jquery.com/hover/\n[`jQuery.off`]: http://api.jquery.com/off/\n[`jQuery.on`]: http://api.jquery.com/on/\n[Function]: http://api.jquery.com/Types/#Function\n[Event]: http://api.jquery.com/Types/#Event\n[Object]: http://api.jquery.com/Types/#Object\n[RequireJS]: https://github.com/amdjs/amdjs-api/blob/master/AMD.md\n[AMD]: https://github.com/amdjs/amdjs-api/blob/master/AMD.md\n[CommonJS]: http://wiki.commonjs.org/wiki/CommonJS\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fjquery.mousehover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprantlf%2Fjquery.mousehover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fjquery.mousehover/lists"}