• <tfoot id='FRSKj'></tfoot>

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

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

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

        禁用按钮仍然监听点击事件

        时间:2024-04-19

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

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

                  <small id='8LZqd'></small><noframes id='8LZqd'>

                    <tbody id='8LZqd'></tbody>
                  <tfoot id='8LZqd'></tfoot>
                • 本文介绍了禁用按钮仍然监听点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在进行一些 jquery 验证的表单中遇到问题.如果未填写特定输入字段,则应通过添加禁用属性来禁用前进"按钮:

                  I have a problem in a form where I do some jquery validations. If a specific input field is not filled out, it should disable a "step forward" button by adding a disabled attribute:

                  if errors
                    $('.btn-move-forward').attr("disabled", true)
                  

                  这可行,但我在该按钮上也有一个点击事件:(咖啡稿)

                  that works but I also have a click event on that button: (coffeescript)

                  $('.btn-move-forward').click ->
                    $('#step2, #step3').toggle()
                  

                  我希望 .btn-move-forward 在按钮被禁用时不会触发点击事件,但它确实会触发!!

                  I expect .btn-move-forward to not fire the click event when the button is disabled but it does!!

                  首先:我不明白为什么,因为每个浏览器规范都定义不应该发生这种情况.无论如何,我尝试通过执行以下操作来绕过它:

                  First: I don't understand why because every browser spec defines that this should not happen. Anyways, I tried to bypass it by doing the following stuff:

                  $('.btn-move-forward').click ->
                    if !$(this).is(:disabled)
                      $('#step2, #step3').toggle()
                  

                  或者这个

                  $('.btn-move-forward').click ->
                    if $(this).prop("disabled", false)
                      $('#step2, #step3').toggle()
                  

                  或者像这样组合事件监听器:

                  or combining the event listeners like this:

                  $('.btn-move-forward').on 'click', '.btn-move-forward:enabled', ->
                     $('#step2, #step3').toggle()
                  

                  不,所有这些都无法正常工作.该按钮仍用作向前移动按钮.

                  No, all of this won't work properly. The button still behaves as a move-forward button.

                  我想要的只是按钮不监听 onclick 如果它被禁用.

                  All I want is the button not listening to onclick if it is disabled.

                  推荐答案

                  disabled 属性仅适用于表单元素.这意味着除非 .btn-move-forward 元素是

                        <tbody id='ewyJN'></tbody>
                      • <bdo id='ewyJN'></bdo><ul id='ewyJN'></ul>
                      • <legend id='ewyJN'><style id='ewyJN'><dir id='ewyJN'><q id='ewyJN'></q></dir></style></legend>

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

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

                        <tfoot id='ewyJN'></tfoot>