when you click button, add a class, to li and then execute a for loop
< H2 > Code < / H2 > <script>
$(".btn").on("click", function () {
$("li").addClass("add")
for (var i = 0; i < 100000; iPP) {
console.log(i)
}
});
</script>
< H2 > question < / H2 >
1. Find that every time you execute this click event, you must finish executing for before you can add class, to li. Why?
2. Every time you execute click, the loop inside is indispensable. How to optimize this loop?