How can i add onclick atributte to td element? | Sololearn: Learn to code for FREE!


How can i add onclick atributte to td element? In this code i am trying to achieve functionality of checkbox on table cells, by JS, but I can't even achieve to add onclick event handler as everything I tried doesn't work. Pls anybody help me.

5/30/2019 11:37:14 AM


4 Answers

New Answer


Maneren Foremost - I'm glad, I could help. First, spread operator, a quick way to convert something to an array hence the forEach() .chained to it. Second I thought that was the case for the src. Third try - $('td').click((e)=> alert(; And that is what is good about coding, there is an alternative way of doing almost everything. Good Coding


Maneren Remove the src from the script tag at line 114


ODLNT First, thank you a lot (how is this method called?). Second, that src was there because i used it with linked file, in other IDE. Last, why doesn't JQuery's click work here? And btw. meantime i solved it by using for...of loop on document.getElementsByTagName(), nearly same as yours, just more begginer approach.


Thank you again