jquery dialog 打开的时候自动聚焦解决方法
生活随笔
收集整理的這篇文章主要介紹了
jquery dialog 打开的时候自动聚焦解决方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
方法一:
p1_dialog_seniorSearch.dialog({ title:"高級查詢", autoOpen:false,//默認關閉 modal: true,//開啟遮罩層 width:570, height:330, buttons: { "查詢":function(){ seniorSearch(1,20) } , "關閉": function() { p1_dialog_seniorSearch.dialog( "close" ); } }, open:function(event, ui){ $(this).parent().focus(); }//取消獲取焦點 });方法二:
在要焦點的的控件加上 autofocus
如:第一個控件為 datepicker,默認dialog打開會自動彈出日歷
解決:在該dialog加個隱藏input,
<input type="hidden" autofocus/>未加 autofocus,dialog不會聚焦影藏的input的。
參考文章:
http://jqueryui.com/upgrade-guide/1.10/#added-ability-to-specify-which-element-to-focus-on-open
http://stackoverflow.com/questions/1202079/prevent-jquery-ui-dialog-from-setting-focus-to-first-textbox
轉載于:https://www.cnblogs.com/dscms/p/6094807.html
總結
以上是生活随笔為你收集整理的jquery dialog 打开的时候自动聚焦解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Vscode中Latex语法无法出现高亮
- 下一篇: 计算机视觉必修