r/PyScript • u/EnderF • Sep 19 '23
py-click: send self to function
Hello,
I am trying to modify the element clicked (remove a class), but so far it doesn't work but it seems to work in javascript onClick. Here is the offender:
li = document.createElement('li')
li.classList.add(tag_class + '-' + str(i))
li.classList.add('collapsed')
li.setAttribute('py-click', 'toggle_collapse(this)')
Error message: name 'this' is not defined
Is there a way for me to achieve that full python?
3
Upvotes
View all comments
Show parent comment
1
u/EnderF Sep 21 '23
Thanks