+ 1

How can i add onclick atributte to td element?

https://code.sololearn.com/WJ1nxmnVYS3Q/?ref=app 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.

30th May 2019, 11:37 AM
Maneren
Maneren - avatar
4 odpowiedzi
+ 2
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. https://codeburst.io/a-simple-guide-to-destructuring-and-es6-spread-operator-e02212af5831 Second I thought that was the case for the src. Third try - $('td').click((e)=> alert(e.target.textContent)); https://code.sololearn.com/WNi64p21DnJb/#html And that is what is good about coding, there is an alternative way of doing almost everything. Good Coding
30th May 2019, 2:13 PM
ODLNT
ODLNT - avatar
+ 3
Maneren Remove the src from the script tag at line 114 https://code.sololearn.com/Wy1uhyUyHxQL/#html
30th May 2019, 12:31 PM
ODLNT
ODLNT - avatar
+ 1
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.
30th May 2019, 1:10 PM
Maneren
Maneren - avatar
+ 1
Thank you again
30th May 2019, 5:34 PM
Maneren
Maneren - avatar