<tfoot id='jC97w'></tfoot>
    <bdo id='jC97w'></bdo><ul id='jC97w'></ul>

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

    <legend id='jC97w'><style id='jC97w'><dir id='jC97w'><q id='jC97w'></q></dir></style></legend>

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

    2. javascript click 事件处理程序在不点击的情况下触发

      时间:2023-09-05
        <bdo id='fLd6f'></bdo><ul id='fLd6f'></ul>

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

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

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

                <tbody id='fLd6f'></tbody>
                本文介绍了javascript click 事件处理程序在不点击的情况下触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                为什么这个函数在没有点击指定按钮的情况下被触发?我看了一些类似的问题,但没有一个处理这个代码结构(可能是我失踪的明显原因......).

                Why does this function get fired without having clicked on the specified button? I had a look at a few similar problems but none deal with this code structure (might be obvious reason for this im missing...).

                document.getElementById("main_btn").addEventListener("click", hideId("main");
                
                function hideId(data) {
                    document.getElementById(data).style.display = "none";
                    console.log("hidden element #"+data);
                }
                

                推荐答案

                你是直接调用它.

                document.getElementById("main_btn").addEventListener("click", hideId("main");
                

                你应该在回调中这样做.

                You should do that in a callback.

                document.getElementById("main_btn").addEventListener("click", function (){
                    hideId("main");
                });
                

                这篇关于javascript click 事件处理程序在不点击的情况下触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:检测由 Tab 键启动的焦点? 下一篇:按钮 onclick 函数触发两次

                相关文章

                最新文章

              • <tfoot id='qHGl0'></tfoot>
              • <small id='qHGl0'></small><noframes id='qHGl0'>

                  <bdo id='qHGl0'></bdo><ul id='qHGl0'></ul>
                <legend id='qHGl0'><style id='qHGl0'><dir id='qHGl0'><q id='qHGl0'></q></dir></style></legend>

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