0
    <a class="flink" href="menushka.html">
    <div class="winimg"><img class="winyar" src="./img/tools.png"></div>
    <div class="wintxt">work</div>
   </a> 

js

var img = document.getElementsByClassName('flink')[0];

img.addEventListener('click', function(event) {
  event.preventDefault();
});

img.addEventListener('dblclick', function(event) {
  this.parentElement.click();
});

Why this code doesn't work? If I just click on this image it has to do nothing,but then I double click on this link it has to work.

mex111
  • 77
  • 1
  • 1
  • 8
  • `document.getElementsByClassName` is for arrays, for multiple elements with the same `class`. use `document.getElementById' , or if you want to keep `class` anyway, use document.getElementsByClassName('flink')[0]; – K. P. May 26 '18 at 16:14
  • doesn't work... – mex111 May 26 '18 at 16:16

0 Answers0