DiegoP.
DiegoP.

Reputation: 45737

jQuery textarea onclick out

Hello I have a textarea.

On Focus a new div will show up, it is a counter.

The problem is that I want to Hide this DIV again when the textarea does not have the focus anymore. So maybe onClickout?

Is there a way to achieve this?

This is what I am using to show the DIV, now I need to hide it when the textarea does not have the focus on.

$("#message").focus(function(){
        $(".counter").fadeIn();
});

Upvotes: 0

Views: 1122

Answers (1)

Guffa
Guffa

Reputation: 700432

The partner of the focus event is the blur event:

$("#message").focus(function(){
  $(".counter").fadeIn();
}).blur(function(){
  $(".counter").fadeOut();
});

Upvotes: 1

Related Questions