Side navigation
#4919 closed feature (wontfix)
Opened July 18, 2009 01:39PM UTC
Closed January 13, 2011 09:07PM UTC
Add a hoverClass method
| Reported by: | joern | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next | 
| Component: | attributes | Version: | 1.3.2 | 
| Keywords: | Cc: | ||
| Blocked by: | Blocking: | 
Description
The following 5 lines are repeated across applications and plugins again and again. I propose to add a plugin method to jQuery core to reduce these to simple one liners:
$(".selector").hover(function() {
  $(this).addClass("class");
}, function() {
  $(this).removeClass("class");
});
Plugin method and usage:
$.fn.hoverClass = function(hoverClass) {
  return this.hover(function() {
    $(this).addClass(hoverClass);
  }, function() {
    $(this).removeClass(hoverClass);
  });
});
$(".selector").hoverClass("class");
Attachments (0)
Change History (6)
Changed July 20, 2009 02:23AM UTC by comment:1
Changed October 22, 2010 06:23PM UTC by comment:2
| component: | core → attributes | 
|---|---|
| keywords: | → event attributes | 
| milestone: | 1.4 → 1.5 | 
| priority: | major → low | 
| status: | new → open | 
Changed November 13, 2010 11:10PM UTC by comment:3
This is pretty much duplicating the functionality already available in CSS with :hover pseudo-classes.
Changed December 14, 2010 11:26AM UTC by comment:4
You can use:
$("#div1").hover(function(){
$("#div1").toggleClass("bgcolor");
});
Instead of:
$("#div1").toggleClass("bgcolor");
Changed January 12, 2011 02:05AM UTC by comment:5
| keywords: | event attributes → needsreview | 
|---|---|
| milestone: | 1.5 → 1.next | 
Changed January 13, 2011 09:07PM UTC by comment:6
| keywords: | needsreview | 
|---|---|
| resolution: | → wontfix | 
| status: | open → closed | 
Following on from Scott_Gonzalez, the dev thread above and here point to there being a group consensus that this wouldn't really be that useful. We're closing as wontfix for now, unless there is a massive change in group thinking on why this shouldnt be the case.
See jquery-dev thread.