Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No mouseup after losing hover

http://jsfiddle.net/rpfHw/

We have an input and class active, which is added on mousedown and removed on mouseup.

It works good when mouse cursor is placed over input.

The problem is, mouseup doesn't work after you click on input, hold and remove cursor from it - class active is not removed.

Can it be fixed?

like image 799
Jasper Avatar asked Dec 02 '25 02:12

Jasper


2 Answers

That's because mouseup was not fired on the input, but outside it. You can use a generic event handler on the document object for that:

$(document).mouseup(function() {
    $('input.active').removeClass('active');
});

http://jsfiddle.net/rpfHw/1/

like image 111
bfavaretto Avatar answered Dec 04 '25 17:12

bfavaretto


I will propose a CSS solution. You can achive the same effect with this rules:

input:active{
    outline: 10px solid #000;
}

(IE8+)

http://jsfiddle.net/rpfHw/6/

like image 23
dfsq Avatar answered Dec 04 '25 15:12

dfsq



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!