Re: [brython] The onclick event attribute

20 views
Skip to first unread message

Kiko

unread,
Jul 26, 2017, 1:57:36 AM7/26/17
to bry...@googlegroups.com

2017-07-21 23:19 GMT+02:00 frederic kavita <amihaco...@gmail.com>:
hi everybody, 
i have this problem The onclick event attribute does not appear in the div

my code :

badge = html.DIV(Class="w3-center w3-display-bottommiddle", id="badge", style={"display": "none"})
for  i in range(1, 6):
ert = "currentDiv({it})".format(it= str(i))
print(ert)
badge <= html.SPAN(Class=" w3-badge demo w3-border w3-transparent w3-hover-white", onclick=ert)



<span class=" w3-badge demo w3-border w3-transparent w3-hover-white"></span><span class=" w3-badge demo w3-border w3-transparent w3-hover-white"></span><span class=" w3-badge demo w3-border w3-transparent w3-hover-white"></span><span class=" w3-badge demo w3-border w3-transparent w3-hover-white"></span><span class=" w3-badge demo w3-border w3-transparent w3-hover-white"></span

thank

You are using the onclick event on a SPAN element and not on a DIV. And you should pass a callable and you are passing an expression.

See the example below:

It provides you with a way to add events to HTML elements.

I hope it helps.

frederic kavita

unread,
Jul 28, 2017, 3:46:57 PM7/28/17
to brython
yes thank you
Reply all
Reply to author
Forward
0 new messages