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

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

<legend id='ndXeh'><style id='ndXeh'><dir id='ndXeh'><q id='ndXeh'></q></dir></style></legend>
  • <tfoot id='ndXeh'></tfoot>
      <bdo id='ndXeh'></bdo><ul id='ndXeh'></ul>

      1. <i id='ndXeh'><tr id='ndXeh'><dt id='ndXeh'><q id='ndXeh'><span id='ndXeh'><b id='ndXeh'><form id='ndXeh'><ins id='ndXeh'></ins><ul id='ndXeh'></ul><sub id='ndXeh'></sub></form><legend id='ndXeh'></legend><bdo id='ndXeh'><pre id='ndXeh'><center id='ndXeh'></center></pre></bdo></b><th id='ndXeh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ndXeh'><tfoot id='ndXeh'></tfoot><dl id='ndXeh'><fieldset id='ndXeh'></fieldset></dl></div>
      2. 按鈕 onclick 函數觸發兩次

        button onclick function firing twice(按鈕 onclick 函數觸發兩次)
              <tbody id='mkfwp'></tbody>

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

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

                <legend id='mkfwp'><style id='mkfwp'><dir id='mkfwp'><q id='mkfwp'></q></dir></style></legend>
                  <bdo id='mkfwp'></bdo><ul id='mkfwp'></ul>
                  <i id='mkfwp'><tr id='mkfwp'><dt id='mkfwp'><q id='mkfwp'><span id='mkfwp'><b id='mkfwp'><form id='mkfwp'><ins id='mkfwp'></ins><ul id='mkfwp'></ul><sub id='mkfwp'></sub></form><legend id='mkfwp'></legend><bdo id='mkfwp'><pre id='mkfwp'><center id='mkfwp'></center></pre></bdo></b><th id='mkfwp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mkfwp'><tfoot id='mkfwp'></tfoot><dl id='mkfwp'><fieldset id='mkfwp'></fieldset></dl></div>
                  本文介紹了按鈕 onclick 函數觸發兩次的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個使用事件處理程序調用 javascript 函數的按鈕.由于某種原因,事件處理程序被調用了兩次.

                  I have a button that calls a javascript function using an event handler. For some reason, the event handler is being called twice.

                  這是我的按鈕(我使用 php 對象來生成代碼,這就是為什么有很多空標簽的原因):

                  Here is my button (I am using a php object to generate the code, that's why there are a lot of empty tags):

                  <button name="addToCart" value="" size="" onclick="" src="" class="addToCartButton" id="0011110421111" type="button" formtarget="_self" formmethod="post" formaction="" data-mini="true" width="" height="" placeholder="" data-mini="1" onkeypress="" >Add To Cart</button>
                  

                  這是我的事件處理程序:

                  Here is my event handler:

                  $('.addToCartButton').click(function() {
                      alert("bob");
                      //addToCart($(this).attr("id"));
                  });
                  

                  在這里,我收到了兩次警報.

                  Here, I am getting the alert twice.

                  我曾嘗試在按鈕的 onclick 屬性中調用函數 addToCart,但如果我這樣嘗試,我會收到此錯誤:

                  I have tried calling the function addToCart in the button's onclick property, but if I try it that way, I get this error:

                  TypeError: '[object HTMLButtonElement]' is not a function (evaluating 'addToCart(0011110421111)')
                  

                  我也嘗試過 event.preventDefault() 和 event.stopPropagation(),但都沒有成功.

                  I have also tried event.preventDefault() and event.stopPropagation(), and neither worked.

                  任何想法為什么會發生這種情況,或者我可以做些什么來阻止它執行兩次,或者如果我從 onclick="" 調用 javascript 函數可能會出現錯誤?

                  Any ideas why this is happening, or what I can do to stop it from executing twice, or maybe why I am getting an error if I call the javascript function from onclick=""?

                  推薦答案

                  也許你在同一個按鈕上附加了兩次事件.您可以做的是取消綁定任何以前設置的點擊事件,如下所示:

                  Maybe you are attaching the event twice on the same button. What you could do is unbind any previously set click events like this:

                  $('.addToCartButton').unbind('click').click(function() {
                      alert("bob");
                      //addToCart($(this).attr("id"));
                  });
                  

                  這適用于所有附加事件(鼠標懸停、鼠標懸停、單擊...)

                  This works for all attached events (mouseover, mouseout, click, ...)

                  這篇關于按鈕 onclick 函數觸發兩次的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 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 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                • <legend id='IXk3N'><style id='IXk3N'><dir id='IXk3N'><q id='IXk3N'></q></dir></style></legend>

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

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

                          • 主站蜘蛛池模板: 久久久久综合 | 日韩a在线 | 亚洲成人免费 | 久久久久一区二区三区 | 亚洲一区二区高清 | 成人午夜电影在线观看 | 中文字幕成人在线 | 最新超碰| 亚洲日本一区二区三区四区 | av在线免费网 | 狠狠躁躁夜夜躁波多野结依 | 亚洲不卡 | 免费观看一级毛片 | 午夜影院污| 日韩在线不卡 | 一级少妇女片 | 一区二区三区日韩 | 亚洲精品在线免费 | 操网站 | 人人鲁人人莫人人爱精品 | 超碰在线人人 | 日韩一区二区在线观看视频 | 国产午夜影院 | 亚洲高清在线 | 亚洲精品视频免费观看 | 亚洲一区二区三区视频 | 国产一区二区在线免费视频 | 亚洲欧美久久 | 久久精品99 | 蜜桃av人人夜夜澡人人爽 | 成人在线观看欧美 | 国产一区91在线 | 天堂资源 | 久久精品男人的天堂 | 激情欧美日韩一区二区 | 欧美视频一区二区三区 | 国产精品高潮呻吟久久 | 国产美女视频一区 | 在线免费观看日本 | 精品视频一区二区三区在线观看 | 麻豆久久久久久久久久 |