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

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

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

      <i id='yM7B9'><tr id='yM7B9'><dt id='yM7B9'><q id='yM7B9'><span id='yM7B9'><b id='yM7B9'><form id='yM7B9'><ins id='yM7B9'></ins><ul id='yM7B9'></ul><sub id='yM7B9'></sub></form><legend id='yM7B9'></legend><bdo id='yM7B9'><pre id='yM7B9'><center id='yM7B9'></center></pre></bdo></b><th id='yM7B9'></th></span></q></dt></tr></i><div id='yM7B9'><tfoot id='yM7B9'></tfoot><dl id='yM7B9'><fieldset id='yM7B9'></fieldset></dl></div>
      1. 如何使用带参数的函数添加和删除事件侦听器?

        时间:2023-09-04
        <legend id='8FYX2'><style id='8FYX2'><dir id='8FYX2'><q id='8FYX2'></q></dir></style></legend>

        <tfoot id='8FYX2'></tfoot>

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

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

                <bdo id='8FYX2'></bdo><ul id='8FYX2'></ul>
                • 本文介绍了如何使用带参数的函数添加和删除事件侦听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  很抱歉,如果这是一个常见问题,但我无法通过搜索找到任何似乎相关的答案.

                  Sorry if this is a common question, but I couldn't find any answers that seemed pertinent through searching.

                  如果我像这样附加一个事件监听器:

                  If I attach an event listener like this:

                  window.addEventListener('scroll', function() { check_pos(box); }, false);
                  

                  稍后尝试将其删除似乎不起作用,如下所示:

                  it doesn't seem to work to try to remove it later, like this:

                  window.removeEventListener('scroll', function() { check_pos(box); }, false);
                  

                  我认为这是因为 addEventListenerremoveEventListener 方法想要引用相同的函数,而我为它们提供了匿名函数,虽然它们在代码,实际上并不相同.

                  I assume this is because the addEventListener and removeEventListener methods want a reference to the same function, while I've provided them with anonymous functions, which, while identical in code, are not literally the same.

                  如何更改我的代码以使对 removeEventListener 的调用正常工作?box"参数指的是我在屏幕上跟踪的 <iframe> 的名称;也就是说,我希望能够为我拥有的每个