jQuery event can't trigger when the target position changed -
I met a strange issue when using the jQuery event, here's the thing:
One The form needs to be valid, so we add a When you end the input in an input field, click the submit button directly. Expected Result: Check that user input is valid, if so, trigger the click event of the submit button. The actual result is: the I tried in JSField, and found that in the general case, the blurred event and click event will be triggered. But what's happened here is: Is this a bug of jQuery? Does anyone participate in this problem? Of course it is that any help would be appreciated. Not a bug blurring event listener to the form for all inputs, when an input focus is lost, the listener will be valid if user input is valid, if Otherwise, an error message will appear below the input, thus pushing the HTML elements down . And we also force click the event for a button to submit the form. blurring of the input will be triggered, but the click event will not be triggered whenever the user input is valid. Blurred in the event handler, we changed the page layout, the status of the submit button changed, thus click was not triggered. focusout is triggered before click , because click is not one-state Not the event There are 2 states in: Mousetown and mouseup . You should not do such a layout in the form , but if you really want to do this, then you can use some additional investigation like mousedown
var mouse_down = false; $ (Function () ($ ('function'). ('Focusout', function (e) {console.log ('focus event:% o', e); if (mouse_down) {mouse_down = false; $ (' $ ('# Test'). Css ({'margin-bottom': '100px'});}); $ ('# button')., Function (e ) {console.log (click on 'event:% o', e);}); $ ('# button'). ('moushudown', function (e) {mouse_down = true;}); $ (document) ) .on ('mouseup', function (e) {mouse_down = false;});})
Comments
Post a Comment