VinithaNarayanan2020 / Myproject

0 stars 0 forks source link

Bind events to the parent element itself #3

Open KarthikaRamachandran opened 3 months ago

KarthikaRamachandran commented 3 months ago

In line number 402 and 404, binding click to individual elements is a costliest operations. So, bind event to the container tabs element itself and use closest method to identify the exact tab and do the operations accordingly. By this way, we can avoid looping and event binding too.

tabs.forEach((tab, index) => {
            tab.addEventListener("click", () => {