I have a list with a lot of p tags in it. Based on those p tags I will fill another div. I passed this on by having onclick="function(this)" inside my li element. Due to some changes I changed my code and I am now building my list using javascript. But I don't know how to pass the onclick function to my list.


document.getElementById("list").addEventListener("click", function fillDiv(this);
document.getElementById("list").onclick = fillDiv(this);


li.onclick = "fillDiv(this)";

无法完全弄清楚如何将“ this”作为参数传递,因为知道单击了哪个列表元素很重要。