简体   繁体   中英

focus is not working after the blur event to the textbox in jquery

while dragging the div, i need to remove the focus of the input and on dropping it, add focus. I have enclosed my code here.

$('.ui-draggable').mousedown(function(){ 
    $(this).find('input').blur();
    $(this).addClass('draggable');
}).mouseup(function(){ 
    $('.draggable').find('input').focus();
    $(this).removeClass('draggable');
});

I don't think you need to call 'blur', as the input will lose focus when you click the ui-draggable element. You should probably use the stop-event of draggable .

$('.ui-draggable').on( "dragstop", function( event, ui ) {
    $('yourinputselector').focus();
});

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