使用 jQuery 的 each() 打开下载 windows

Open download windows using jQuery's each()

我有一个 table 包含几行,其中每一行代表一个 exportable 文件,例如。 G。:

<tr>
  <th class="text-center" scope="row">
    <input id="exportID-23" type="checkbox" />
  </th>
  <td class="text-center text-nowrap">2016-08-24</td>
  <td>Name</td>
  <td>City</td>
  <td class="text-center text-nowrap">Person</td>
</tr>
[...]
<button id="exports" class="btn btn-success" type="button">
  <span class="glyphicon glyphicon-export"></span> Export
</button>

为了 return 只有那些在用户单击导出按钮时请求的文件,我这样写:

$('#exports').click(function () {
  var exports = $(this);

  $('[id^=exportID-]').each(function () {
    if (this.checked) {
      window.open('ajax/get-exports.php?ExportID=' + this.id.substring(9));
    }
  });
});

现在,使用 Firefox 的开发人员控制台调试我的代码,each() 按预期工作:每次下载我都会得到一个新的 window。
但是,运行 没有调试器的相同代码,它只为最后选定的行打开一个新的 window。

不幸的是,我找不到这个问题的答案 - 无论是在 SO 上还是在 Internet 深处的其他地方,所以:我做错了什么?

To open a new window on every call of window.open(), use the special value _blank for strWindowName.

https://developer.mozilla.org/en-US/docs/Web/API/Window/open(示例部分第一段结尾)

打开开发人员控制台并执行您的代码通常可以消除缓存问题。你能不能做一个 CTRL + SHIFT + DEL 并清除你的缓存并尝试在没有的情况下执行你的代码开发者控制台打开。

希望对您有所帮助!