0

Trying to make some good accessible cards but having trouble with IE11 (no surprise). Pretty sure I'm missing something obvious? I know it is an issue with the js but brain is having trouble getting in to gear :/

const cards = document.querySelectorAll('.card');  
Array.prototype.forEach.call(cards, card => {  
    let down, up, link = card.querySelector('h4 a');            
    card.style.cursor = 'pointer';
    card.onmousedown = () => down = +new Date();
    card.onmouseup = () => {
        up = +new Date();
        if ((up - down) < 200) {
            link.click();
        }
    }
});
Lee
  • 23
  • 1
  • 4

2 Answers2

1

Try to use the basic function

Internet explorer dont support es6 syntax(arrow function)

Check this links out for more

IE array function stack overflow discussion

github discussion

Arun
  • 601
  • 10
  • 15
0

Ah yeah, forgot IE11 was no good with es6. Full hand it is! I hate it when a project demands IE support.

var cards = document.querySelectorAll('.card');
Array.prototype.forEach.call(cards, function (card) {
  var down,
      up,
      link = card.querySelector('h4 a');
  card.style.cursor = 'pointer';

  card.onmousedown = function () {
    return down = +new Date();
  };

  card.onmouseup = function () {
    up = +new Date();

    if (up - down < 200) {
      link.click();
    }
  };
});
Lee
  • 23
  • 1
  • 4