0

Typical code works like this:

$(...).hover(function () {});.

But it also needs to go away when it's loses it's hover. Is there a shorter way to do that than:

$("#x").hover(function () { troll(); });
$("#x").mouseout(function () { untroll(); });

I just feel that smart people over at jQuery have thought of that and there must be a function that fuses them both.
I tried something like this:

$(xxx)
        .hover(function () {
            $(xxx).animate({"opacity": 1});
        })
        .mouseout(function () {
            $(xxx).css({"opacity": 0});
        });

But that has long history of failures (item doesn't animate, then goes back to 0, then goes to 1, then smoothly warps to 0, it doesn't work, long story).

addClass() and removeClass() are not an option. Due to other CSS properties like "display: none".

Et cetera. Et cetera. Et cetera. Et cetera.

2
Contributors
2
Replies
10
Views
1 Year
Discussion Span
Last Post by Aeonix
1

Seems you mixed two different events. try:

$( xxx ).hover(
  function() {
    $( this ).animate({"opacity": 1});
  }, function() {
    $( this ).css({"opacity": 0});
  }
);

The hover event haas two params - one for hoverIn and one for hoverOut

0

Exactly that. Sometimes I bring back the idea to look up manual sometimes, instead of relying on own "knowledge".

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.