Opened 14 years ago
Closed 12 years ago
#4919 closed feature (wontfix)
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");
Change History (6)
comment:1 Changed 14 years ago by
comment:2 Changed 12 years ago by
Component: | core → attributes |
---|---|
Keywords: | event attributes added |
Milestone: | 1.4 → 1.5 |
Priority: | major → low |
Status: | new → open |
comment:3 Changed 12 years ago by
This is pretty much duplicating the functionality already available in CSS with :hover pseudo-classes.
comment:4 Changed 12 years ago by
You can use:
$("#div1").hover(function(){
$("#div1").toggleClass("bgcolor");
});
Instead of:
$("#div1").toggleClass("bgcolor");
comment:5 Changed 12 years ago by
Keywords: | needsreview added; event attributes removed |
---|---|
Milestone: | 1.5 → 1.next |
comment:6 Changed 12 years ago by
Keywords: | needsreview removed |
---|---|
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.