Benjamin RD
Benjamin RD

Reputation: 12044

jQuery delegate focusout or blur event

I have the next code declared in my on ready:

jQuery("body").delegate(".ta_obsn", "focusout", function() {
  alert("Fired method");
  jQuery(".tas")
    .append('<textarea type="text" class="form-control" class="ta_observacion"></textarea>');
});

This problems occurs with the focusout and blur methods, but if I replace the changeinstead focusout the method is fired.

How I can use focousout using delegate (or similar behavior)?

Upvotes: 0

Views: 1951

Answers (3)

mplungjan
mplungjan

Reputation: 178350

We nowadays delegate with .on, in your case

$("body").on("focusout",".ta_obsn", function() ...

Upvotes: 2

jagdish.narkar
jagdish.narkar

Reputation: 317

You should use .on with latest jQuery:

$('body').on('blur','.ta_obsn',function(){
//Your code goes here
});

Upvotes: 0

Stavm
Stavm

Reputation: 8131

As of jQuery 3.0, .delegate has been deprecated we now use the .on() instead http://api.jquery.com/delegate/

seems fine with the none deprecated '.on()' method

 $("input").on("focusout", function() {
        $("div").append('focusout invoked ! ');
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
  
</div>
<input type="text">
<input type="text">

Upvotes: 0

Related Questions