jquery dialog開啟時,焦點自動在第一個text框上

來源:互聯網
上載者:User

今天在用jqueryui的日曆功能,datepicker時碰到一個問題。輸入框在一個彈出的jquery dialog中,每次dialog(“open”)的時候,對話方塊的焦點自動focus到第一個<input type="text"/>框,正好這個input框綁定了datepicker,就自動把日曆彈出來了。

google了一下,還真碰到正好也有這個問題的:

http://stackoverflow.com/questions/1202079/prevent-jquery-ui-dialog-from-setting-focus-to-first-textbox

裡面有提到jquery對話方塊開啟時,哪個元素獲得焦點的機制:

http://jqueryui.com/upgrade-guide/1.10/#added-ability-to-specify-which-element-to-focus-on-open

在jqueryui 1.10.0之後,對話方塊開啟時,第一個設定了autofocus的元素獲得焦點。

在jqueryui 1.10.0之前:tabbable elements within the content area, tabbable elements within the button pane, the close button, and finally the dialog itself as a fallback。即:對話方塊主體內容中第一個支援tab鍵的元素;如果沒找到,則尋找button部分第一個支援tab鍵的元素;再沒找到,則close按鈕獲得焦點;最後沒有的話,整個對話方塊獲得焦點

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.