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

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

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

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

        事件不適用于動態創建的元素

        Event not working on dynamically created element(事件不適用于動態創建的元素)
        1. <tfoot id='FsuDH'></tfoot>

            <bdo id='FsuDH'></bdo><ul id='FsuDH'></ul>

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

              <i id='FsuDH'><tr id='FsuDH'><dt id='FsuDH'><q id='FsuDH'><span id='FsuDH'><b id='FsuDH'><form id='FsuDH'><ins id='FsuDH'></ins><ul id='FsuDH'></ul><sub id='FsuDH'></sub></form><legend id='FsuDH'></legend><bdo id='FsuDH'><pre id='FsuDH'><center id='FsuDH'></center></pre></bdo></b><th id='FsuDH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FsuDH'><tfoot id='FsuDH'></tfoot><dl id='FsuDH'><fieldset id='FsuDH'></fieldset></dl></div>
                  <tbody id='FsuDH'></tbody>
                <legend id='FsuDH'><style id='FsuDH'><dir id='FsuDH'><q id='FsuDH'></q></dir></style></legend>
                • 本文介紹了事件不適用于動態創建的元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在努力弄清楚為什么 mouseover 事件不能與 .on 處理程序一起使用,該處理程序是從 ajax 動態創建的元素.似乎唯一可行的是帶有 .live 的代碼,但我知道它已被棄用.

                  $(".dropdown ul li").live("mouseover", function() {alert('鼠標懸停工作');});

                  但是,當我嘗試使用 .on 時,它不起作用 - 無論我嘗試什么變體(document.ready、.mouseover 等)

                  $(".dropdown ul li").on("mouseover", function() {alert('鼠標懸停工作');});

                  事件處理程序位于代碼的底部,因此它們最后執行.有人知道我做錯了什么嗎?

                  解決方案

                  .on 用于具有動態事件委托 http://api.jquery.com/on/ - 你的主選擇器是一個存在的static parent:

                  $(".static-parent").on("event1 event2", ".dynamic-child", function() {

                  或者在你的情況下:

                  $(".dropdown").on("mouseover", "li", function() {alert('鼠標懸停工作!!!!!!!!!');});

                  <塊引用>

                  委托事件的優點是它們可以處理來自以后添加到文檔的后代元素的事件.通過選擇在附加委托事件處理程序時保證存在的元素,您可以使用委托事件來避免頻繁附加和刪除事件處理程序的需要.例如,該元素可以是模型-視圖-控制器設計中視圖的容器元素,或者如果事件處理程序想要監視文檔中的所有冒泡事件,則可以是文檔.在加載任何其他 HTML 之前,文檔元素在文檔的頭部是可用的,因此在此處附加事件是安全的,而無需等待文檔準備好.

                  還要確保使用 DOM 就緒 函數

                  jQuery(function($) {//DOM 現已準備就緒,$ 別名已保護$(".dropdown").on("mouseover", "li", function() {alert('鼠標懸停工作!!!!!!!!!');});});

                  I'm pulling my hair out trying to figure out why the mouseover event won't work with the .on handler with a dynamically created element from ajax. The only thing that seems to work is the code with .live but I understand that it is deprecated.

                  $(".dropdown ul li").live("mouseover", function() {
                  alert('mouseover works');
                  });
                  

                  However, when I try using .on, it will not work - no matter what variations I try (document.ready, .mouseover, etc etc)

                  $(".dropdown ul li").on("mouseover", function() {
                  alert('mouseover works');
                  });
                  

                  The event handlers are at the bottom of the code, so they are executed last. Anyone have an idea of what I'm doing wrong??

                  解決方案

                  Using .on for newly generated elements with dynamic event delegation http://api.jquery.com/on/ - where your main selector is an existent static parent:

                  $(".static-parent").on("event1 event2", ".dynamic-child", function() {
                  

                  or in your case:

                  $(".dropdown").on("mouseover", "li", function() {
                     alert('mouseover works!!!!!!!!!');
                  });
                  

                  Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time. By picking an element that is guaranteed to be present at the time the delegated event handler is attached, you can use delegated events to avoid the need to frequently attach and remove event handlers. This element could be the container element of a view in a Model-View-Controller design, for example, or document if the event handler wants to monitor all bubbling events in the document. The document element is available in the head of the document before loading any other HTML, so it is safe to attach events there without waiting for the document to be ready.

                  Also make sure to use a DOM ready function

                  jQuery(function($) { // DOM is now ready and $ alias secured
                  
                      $(".dropdown").on("mouseover", "li", function() {
                         alert('mouseover works!!!!!!!!!');
                      });
                  
                  });
                  

                  這篇關于事件不適用于動態創建的元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Angular 2 (Ionic 2): intercept ajax requests(Angular 2 (Ionic 2):攔截 ajax 請求)
                  Angular 2 HTTP Progress bar(Angular 2 HTTP 進度條)
                  Is there an HTML attribute/event handler for #39;on mouse release#39;?(是否有用于“鼠標釋放的 HTML 屬性/事件處理程序?)
                  Printing from an application in IIS to a networked printer on server(從 IIS 中的應用程序打印到服務器上的網絡打印機)
                  angular2 posting XML type request data using HTTP(angular2 使用 HTTP 發布 XML 類型的請求數據)
                  Storing HTML5 geolocation data(存儲 HTML5 地理位置數據)
                • <small id='8ljJY'></small><noframes id='8ljJY'>

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

                            <legend id='8ljJY'><style id='8ljJY'><dir id='8ljJY'><q id='8ljJY'></q></dir></style></legend>

                            主站蜘蛛池模板: 黄视频网址| 国产精品二区三区在线观看 | 岛国av一区二区三区 | 四虎成人免费电影 | 91视频导航 | 亚洲国产一区二区在线 | 中文字幕精品一区二区三区精品 | 97精品超碰一区二区三区 | 日本涩涩网 | www.一级毛片| 夜夜夜久久久 | 中文字幕一区二区三区四区 | 久草在线免费资源 | 日韩欧美视频在线 | 岛国av在线免费观看 | 精品国产精品 | 久久99精品久久久久 | 色噜噜亚洲男人的天堂 | 在线国产中文字幕 | 在线2区 | 国产欧美一区二区三区在线看 | 亚洲一区中文字幕 | 久久国产精品网站 | 国产一二三区免费视频 | 精品国产一区二区久久 | 在线观看国产视频 | 狠狠的日 | 欧美国产视频 | 女人精96xxx免费网站p | 一区二区免费在线视频 | www.天天操.com | 狠狠干狠狠操 | 亚洲狠狠爱 | 波多野结衣av中文字幕 | 国产视频1区 | 国产成人99久久亚洲综合精品 | 国产精品久久久久久久久久久免费看 | 久久aⅴ乱码一区二区三区 亚洲欧美综合精品另类天天更新 | 美女黄色在线观看 | 岛国av在线免费观看 | 日韩欧美中文字幕在线观看 |