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()
)
精彩评论