Keep track of how much time is spent showing certain elements on the page

后端 未结 6 664
情话喂你
情话喂你 2020-12-15 21:06

So lets say we have 4 Divs (3 hidden, 1 visible), the user is able to toggle between them through javascript/jQuery.

I want to calculate time spent on each Div, and

6条回答
  •  死守一世寂寞
    2020-12-15 21:53

    Javascript console internally has a function called "console.time() and console.timeEnd() to do the same. Simple you can use them

    console.time("List API");
    setTimeout(()=> {
      console.timeEnd("List API");
    },5000);

    More details can be found here https://developer.mozilla.org/en-US/docs/Web/API/Console/time

提交回复
热议问题