久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <i id='V1amM'><tr id='V1amM'><dt id='V1amM'><q id='V1amM'><span id='V1amM'><b id='V1amM'><form id='V1amM'><ins id='V1amM'></ins><ul id='V1amM'></ul><sub id='V1amM'></sub></form><legend id='V1amM'></legend><bdo id='V1amM'><pre id='V1amM'><center id='V1amM'></center></pre></bdo></b><th id='V1amM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='V1amM'><tfoot id='V1amM'></tfoot><dl id='V1amM'><fieldset id='V1amM'></fieldset></dl></div>

        <tfoot id='V1amM'></tfoot>

        • <bdo id='V1amM'></bdo><ul id='V1amM'></ul>

        <small id='V1amM'></small><noframes id='V1amM'>

      1. <legend id='V1amM'><style id='V1amM'><dir id='V1amM'><q id='V1amM'></q></dir></style></legend>

      2. 焦點(diǎn)和模糊 jQuery 事件不冒泡

        Focus and blur jQuery events not bubbling(焦點(diǎn)和模糊 jQuery 事件不冒泡)

            <tbody id='ZzP57'></tbody>
            <i id='ZzP57'><tr id='ZzP57'><dt id='ZzP57'><q id='ZzP57'><span id='ZzP57'><b id='ZzP57'><form id='ZzP57'><ins id='ZzP57'></ins><ul id='ZzP57'></ul><sub id='ZzP57'></sub></form><legend id='ZzP57'></legend><bdo id='ZzP57'><pre id='ZzP57'><center id='ZzP57'></center></pre></bdo></b><th id='ZzP57'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ZzP57'><tfoot id='ZzP57'></tfoot><dl id='ZzP57'><fieldset id='ZzP57'></fieldset></dl></div>
            <legend id='ZzP57'><style id='ZzP57'><dir id='ZzP57'><q id='ZzP57'></q></dir></style></legend>

              <small id='ZzP57'></small><noframes id='ZzP57'>

              1. <tfoot id='ZzP57'></tfoot>

                  <bdo id='ZzP57'></bdo><ul id='ZzP57'></ul>
                  本文介紹了焦點(diǎn)和模糊 jQuery 事件不冒泡的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  具有以下html結(jié)構(gòu):

                  <form><span><input></span></form></div><p>

                  以及下面的jquery代碼:

                  $('form').on("focus", function(event) {$("p").append("焦點(diǎn)沒(méi)有委托<br>");})

                  為什么焦點(diǎn)事件沒(méi)有到達(dá)我的事件處理程序?使用選擇器參數(shù)綁定事件可以正常工作:

                  $('form').on("focus", "input", function(event) {$("p").append("焦點(diǎn)委托<br>");})

                  事件下一個(gè)片段有效,因此焦點(diǎn)事件實(shí)際上會(huì)冒泡......

                  $('form').on("focus", "span", function(event) {$("p").append("焦點(diǎn)委托<br>");})

                  兩種形式都適用于點(diǎn)擊和更改事件:

                  $('form').on("click", function(event) {$("p").append("點(diǎn)擊不委托<br>");})$('form').on("click", "input", function(event) {$("p").append("點(diǎn)擊委托<br>");})

                  我發(fā)現(xiàn)的關(guān)于焦點(diǎn)事件冒泡的唯一說(shuō)明是相對(duì)于我不使用的舊 jQuery 版本.在這里

                  查看它

                  編輯 1

                  這很令人困惑……根據(jù) jQuery 的焦點(diǎn)文檔:

                  <塊引用>

                  焦點(diǎn)事件在 Internet Explorer 中不會(huì)冒泡.因此,依賴(lài)于具有焦點(diǎn)事件的事件委托的腳本將無(wú)法在瀏覽器中一致地工作.然而,從 1.4.2 版本開(kāi)始,jQuery 通過(guò)在其事件委托方法 .live() 和 .delegate() 中將焦點(diǎn)映射到 focusin 事件來(lái)解決此限制.

                  根據(jù)jQuery的focusin doc:

                  <塊引用>

                  focusin 事件在元素或其中的任何元素獲得焦點(diǎn)時(shí)發(fā)送到該元素.這與焦點(diǎn)事件的不同之處在于它支持檢測(cè)父元素上的焦點(diǎn)事件(換句話說(shuō),它支持事件冒泡).

                  對(duì)我來(lái)說(shuō)是太晚了還是兩者相矛盾?

                  解決方案

                  是的,jQuery 文檔似乎具有誤導(dǎo)性.我相信關(guān)于 focus 的文檔忽略了提及這是針對(duì)不涉及用戶輸入的元素(@Ohgodwhy 在您的問(wèn)題評(píng)論中列出了它們).

                  我想這與瀏覽器需要將光標(biāo)捕獲在具有 focus 的輸入元素中有關(guān),以便它可以接受來(lái)自鍵盤(pán)的輸入.換句話說(shuō),如果 jQuery 允許它冒泡,那么您將永遠(yuǎn)沒(méi)有機(jī)會(huì)在輸入字段中輸入內(nèi)容.

                  無(wú)論哪種方式,除非您首先在其上放置 tabindex,否則您將永遠(yuǎn)無(wú)法獲得接受 focus 事件的表單:http://jsfiddle.net/qxLqP/ 但如果基于輸入的字段首先獲得焦點(diǎn),它將永遠(yuǎn)不會(huì)冒泡.默認(rèn)情況下,form 元素沒(méi)有 tabindex,您無(wú)法將焦點(diǎn)設(shè)置到?jīng)]有 tabindex 的內(nèi)容.

                  我會(huì)接受 @Ohgodwhy 的使用 focusin 的解決方案,然后讓 jQuery 團(tuán)隊(duì)了解他們令人困惑的文檔.

                  With the following html structure:

                  <div>
                  <form><span><input></span></form>
                  </div>
                  <p>
                  

                  and the following jquery code:

                  $('form').on("focus", function(event) {
                      $("p").append("focus no delegation<br>");
                  })
                  

                  Why doesn't the focus event ever reach my event handler? Binding the event with a selector parameter works fine:

                  $('form').on("focus", "input", function(event) {
                      $("p").append("focus delegation<br>");
                  })
                  

                  Event the next snippet works so the focus event does in fact bubble...

                  $('form').on("focus", "span", function(event) {
                      $("p").append("focus delegation<br>");
                  })
                  

                  Both forms work with click and change events:

                  $('form').on("click", function(event) {
                      $("p").append("click no delegation<br>");
                  })
                  $('form').on("click", "input", function(event) {
                      $("p").append("click delegation<br>");
                  })
                  

                  The only note I found about the focus event's bubbling is relative to older jQuery versions which I don't use. See it in action here

                  edit 1

                  Well this is confusing... According to jQuery's focus doc:

                  The focus event does not bubble in Internet Explorer. Therefore, scripts that rely on event delegation with the focus event will not work consistently across browsers. As of version 1.4.2, however, jQuery works around this limitation by mapping focus to the focusin event in its event delegation methods, .live() and .delegate().

                  And according to jQuery's focusin doc:

                  The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

                  Is it too late for me or does one contradict the other?

                  解決方案

                  Yes, it appears the jQuery docs are misleading. I believe the documentation on focus neglected to mention that this was for the elements that aren't involved in user input (@Ohgodwhy listed them above in your question's comments).

                  I imagine it has something to do with the browser's need to trap the cursor in the input element that has focus, so that it can accept input from the keyboard. In other words, if jQuery allowed it to bubble, then you would never be given the chance to type in the input field.

                  Either way you'll never get a form to accept a focus event unless you first put a tabindex on it: http://jsfiddle.net/qxLqP/ but if an input based field gets focus first, it will never bubble. By default, the form element doesn't have a tabindex, and you can't set focus to something that doesn't have a tabindex.

                  I'd just accept @Ohgodwhy's solution of using focusin and then go let the jQuery team know about their confusing documentation.

                  這篇關(guān)于焦點(diǎn)和模糊 jQuery 事件不冒泡的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項(xiàng)目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數(shù)據(jù)更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創(chuàng)建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動(dòng)態(tài)元素 - Angular 2 amp;離子2)

                    <tbody id='yVmg1'></tbody>
                  1. <legend id='yVmg1'><style id='yVmg1'><dir id='yVmg1'><q id='yVmg1'></q></dir></style></legend>
                    • <bdo id='yVmg1'></bdo><ul id='yVmg1'></ul>
                        <tfoot id='yVmg1'></tfoot>
                      • <small id='yVmg1'></small><noframes id='yVmg1'>

                          • <i id='yVmg1'><tr id='yVmg1'><dt id='yVmg1'><q id='yVmg1'><span id='yVmg1'><b id='yVmg1'><form id='yVmg1'><ins id='yVmg1'></ins><ul id='yVmg1'></ul><sub id='yVmg1'></sub></form><legend id='yVmg1'></legend><bdo id='yVmg1'><pre id='yVmg1'><center id='yVmg1'></center></pre></bdo></b><th id='yVmg1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yVmg1'><tfoot id='yVmg1'></tfoot><dl id='yVmg1'><fieldset id='yVmg1'></fieldset></dl></div>

                            主站蜘蛛池模板: 亚洲一区中文字幕 | 天天久久 | 日本午夜免费福利视频 | 在线播放一区 | 国产成人免费视频网站视频社区 | 精品久久中文 | 久久伊人青青草 | 国产色婷婷久久99精品91 | 日本激情视频中文字幕 | 伊人春色成人 | 久草在线在线精品观看 | 亚洲一区二区三区在线播放 | 日韩在线小视频 | 成人影院午夜 | 超碰在线播 | 亚洲黄色成人网 | 国产一区三区在线 | av色噜噜 | 久久亚洲精品国产精品紫薇 | 国产精彩视频 | 日韩电影一区二区三区 | 可以在线看的黄色网址 | 欧洲av在线| 日韩在线免费视频 | 男女羞羞视频在线看 | 毛片99| 久久久久久久久久久久久91 | 亚洲一区 中文字幕 | 91精品久久久久久久久久入口 | 亚洲一区二区三区久久 | 欧美电影一区 | 天天干视频网 | 一区二区三区久久久 | 99资源| 日韩精品一区二区三区中文在线 | 精品欧美色视频网站在线观看 | 久久一二| 中国91av| 中文字幕一区在线 | 91中文字幕在线观看 | 超碰男人天堂 |