开发者

Execute another instruction after executing JQuery jAlert plugin

I,m using jalert plu开发者_JAVA技巧gin. It works well but I'd like after showing the message box (dialog) being able to execute another instruction (namely I'm using it to check the empty textboxes in a form before sending them, if a textbox is empty I show the message and I want the textbox to get focus but it never happens.

I've tried using

document.getElementById('txtName').focus(); 

and

$('#txtName').focus();

after

jAlert('message','title');

but neither of them work. After showing the message the function ends.

Thanks for your replies.


The call to jAlert doesn't operate like JavaScript alert, in that any following lines of code will be executed.

According to this thread, jAlert has a callback, which might be able to help you:

jAlert( message, [title, callback] )   

So, you should amend you call to be:

jAlert('message','title', function(){
    $("#txtName").focus();
});

(note: I've jQuery-ized your document.getElementById('txtName') to $("#txtName").focus())

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜