1. Common code, registering an event method on a DOM node
$ ("#btnResponse"). Click (Login); $ ("#txtCode"). KeyDown (Returnkey);
2. Very normal login function, just inside with the Swal plugin
Code execution effect is what I want, click Btnresponse, when meet trigger condition, pop up Swal prompt box, very good.
functionLogin (e) {varLoginuserid = $ ("#txtUserno"). Val ();//User name varPassWord = $ ("#txtPassword"). Val ();//Password varPcode = $ ("#txtCode"). Val ();//Graphics Verification Code //Verify required Fields if(Loginuserid = = =NULL|| Loginuserid.trim () = = = ""{Swal ({title:Failed, Text:"Account cannot be empty", type:"Warning", Showcancelbutton:true, Confirmbuttoncolor:"#DD6B55", Confirmbuttontext:Determine, Closeonconfirm:false }); return false; } //A little ...
3. Do not achieve the desired effect of the Returnkey method design, pop-up Swal prompt brush off immediately, see the difference between login and Returnkey, nothing but returnkey and set a layer, and then call the login method
function Returnkey (event) { if (event.keycode = =){ Login (); }}
Description: Analysis of the above code, returnkey after the completion of login, Returnkey where the execution thread has continued execution, so Swal was brushed off.
4. Change the code to achieve the desired effect, after the carriage return, the Swal pop-up box stays on the page.
function Returnkey (event) { if (Event.keycode = =) { return Login (); Login (); return false; }}
Understanding of function return False in JavaScript (instance code)