Get the App
SLTechnology News&Howtos  ›  Development  › 

How does js add a click event to each li?

Shulou Source: shulou.com Published: 2022-06-03 16:40:32 11月14日 Update

This article mainly explains "how to add a click event for each li by js". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how js can add a click event to each li.

This is the first li, this is the second li, this is the third li.

Answer 1: bind, point the current anonymous function to this and pass in I as a parameter

Var init = function () {var obj = document.getElementById ('text'); for (var iTuno

Tags: Events this is solutions content methods learning practical deeper three interests functions parameters practicality practicality pointing simple operation more friends websites closures Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi NVidia macOS Shulou Information