javascript - button needs to be click twice for onclick to trigger
问题 Why does my button need to be clicked twice for the onclick event to trigger? There're some other thread on stackoverflow with the same problem, but in all the thread i found, the original poster puts the event handler inside the function. It's not like that with my code. Html <body> <ul id="parentList"> <li>First child</li> <li>Second child</li> <li>Third child</li> <li>Forth child</li> <li>Fifth child</li> </ul> <button type="button" id="delete">Delete first child</button> </body> Script: