Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 参考错误-Mozilla Firefox_Javascript_Html_Firefox_Browser_Navigation - Fatal编程技术网

Javascript 参考错误-Mozilla Firefox

Javascript 参考错误-Mozilla Firefox,javascript,html,firefox,browser,navigation,Javascript,Html,Firefox,Browser,Navigation,我在做手机过滤器。有几个按钮。点击每个按钮后接收类有源滤波器基站。我做了所有的事情,但在Firefox测试中,我得到了错误ReferenceError:event未定义。Chrome和Safari工作正常。 你知道为什么Mozilla会看到错误以及如何修复它吗?或者用不同的方式添加活动类 HTML: JS: 试试这个,在firefox中,您必须传递事件对象 Project.Search.selectCategory=functionevent{ ifevent.target.classList

我在做手机过滤器。有几个按钮。点击每个按钮后接收类有源滤波器基站。我做了所有的事情,但在Firefox测试中,我得到了错误ReferenceError:event未定义。Chrome和Safari工作正常。 你知道为什么Mozilla会看到错误以及如何修复它吗?或者用不同的方式添加活动类

HTML:

JS:


试试这个,在firefox中,您必须传递事件对象

Project.Search.selectCategory=functionevent{ ifevent.target.classList.包含“active-filter-BTN”{ 这是一个类别; }否则{ switchevent.target.id{ 案例过滤器btn all: 这是showAllGames; 打破 案例筛选器btn提供程序: 这是一个很好的例子; 打破 案例过滤器btn大奖: 这是一场赌博游戏; 打破 } } if!event.target.classList.包含'filter-btn'{ 回来 } event.target.classList.toggle'active-filter-btns'; 让links=document.queryselectoral'.filter btn'; 对于let i=0;i <div id="search-btns" class="filter-btns"> <button id="filter-btn-all" class="filter-btn" onclick="Project.Search.selectCategory(this.id)">A - Z</button> <button id="filter-btn-provider" class="filter-btn" onclick="Project.Search.selectCategory(this.id)">Providers</button> <button id="filter-btn-jackpot" class="filter-btn" onclick="Project.Search.selectCategory(this.id)">Jackpot</button> </div>
Project.Search.selectCategory = function(event) {
  if(event.target.classList.contains('active-filter-btns')){
    this.showCategories();
  } else {
    switch(e) {
      case "filter-btn-all": 
        this.showAllGames();
        break;
      case "filter-btn-provider":
        this.showProviders();
        break;
      case "filter-btn-jackpot":
        this.showJackpotGames();
        break;
    }
  }

  if (!event.target.classList.contains('filter-btn'))
    return;

  event.target.classList.toggle('active-filter-btns');

  let links = document.querySelectorAll('.filter-btn'); 
  for (let i = 0; i < links.length; i++) {
    if (links[i] === event.target)
      continue;
    links[i].classList.remove('active-filter-btns');
  }
};