简体   繁体   中英

blur event text field jquery

I have the blur event event on a text field

$(document).on('blur', '#inputEmail', function(event){

    // logic here

});

When I put some text in the field click and drag on a draggable element using jQuery draggable , the event does not execute when I drop the element.

How can I fix this? It's kind of annoying.

Thanks in advance

If you want to keep the blur event, it might be a good idea to use the tradition event delegation approach. Listen for the blur event on your input with an id of inputEmail .

$("#inputEmail").on("blur", function(event) {
    alert('hi');
});

http://jsfiddle.net/1qyhjshu/1

Edit: It looks like your first example worked for me as well.

http://jsfiddle.net/vbdxwt9b/

If you want to make hit on the button only after executing the code in blur event.You may hide the button and show he button after executing the blur function.

      $("#inputEmail").blur( function(event) {
      //code here
      $("#btn").show();

      });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM