I have a very specific website in mind in which the words on the webpage are clickable and upon clicking it generates a new DOM element.
I'm trying to create a chrome extension in which when the user clicks on a webpage, the click triggers a function that returns the element generated by it's id.
right now this is what I have
<script>
document.onclick = function(myFunction)
function myFunction() {
var x = document.getElementsById("v0")
return x
}
</script>
I'm unable to see anything logged on console when I load the extension.
is document.onclick the right method to use? and should I use getElementByClassName or getElementById?