This article mainly introduces how jQuery implements dialog to set focus, and involves jQuery's operations on dialog, you can refer to the following example to describe how jQuery implements dialog to set focus. Share it with you for your reference. The specific analysis is as follows:
When the dialog box is displayed, the focus should be directed to the input text box by default, but $ ("# txtGroupName"). focus () is written before dialog. show (); does not take effect.
Check jQuery's official documentation and find that dialog provides a focus parameter. OK. Try ~~
// The Create Project Group dialog box is displayed. function showCreateProjectGroupDialog (I) {$ ("# layout-createProjectGroup-pane "). show (). dialog ({modal: true, title: lmslang. listProjectGroup_Create, width: 450, overlay: {opacity: 0.5}, focus: function (ev, data) {$ ("# txtGroupName "). focus () ;}, buttons: {"save": function () {var name = el ("txtGroupName "). value; var description = el ("txtDescription "). value; var B = $ ("# fgroup "). valid (); if (B) {createGroupJson (); closeCreateGroupDialog ();} else {showError (lmslang. formValidate_Error) ;}}, "cancel": function () {closeCreateGroupDialog () ;}}) ;}// hide the function closeCreateGroupDialog () dialog box of the new project group dialog box () {$ ("# layout-createProjectGroup-pane "). dialog ("close ");}
Done! O (partition _ partition) O ..
I hope this article will help you with jQuery programming.