Hello! There is such a link:

<a href="javascript:void(0)" onclick="showHide('block_id')">Скрыть/Показать элемент</a> 

Do you need to make two clicks on JS after a specified time?

  • Why two clicks? - Anton Shchyrov
  • one
    Use setTimeout() and addEventListener() . - LFC
  • setTimeout (function () {document.getElementById ('fo1'). click ()}, 3000); But here by the element id and this one has no id? - Helpsetup

1 answer 1

As I understand it, you need something onclick. Well, or as noted in the comments it is better to add with addEventListener

  setTimeout(function () { for(let i=0;i<2;i++) showHide('block_id') }, TIMEOUT) 

But if you need to make two clicks at intervals of time, then maybe you are solving a slightly wrong problem. Maybe it needs to be done differently at the root.

  • There is also a block with the same name and then a line for (let i = 0; i <2; i ++) gives an error! - Helpsetup
  • Write down in more detail. What mistake. Where. Which block - Aksenov Vladimir