r/PyScript • • Oct 21 '22
Quick question about .clear()
In this video from May '22 the creator used the following to clear a <textarea>
<textarea id="input_text"></textarea> <!-- this is the textarea that is being cleared -->
<button id="clear" pys-onClick="clear">Clear</button>
...
<py-script>
input_text_element = Element("input_text")
def clear(*args, **kwargs):
input_text_element.clear()
</py-script>Except when I tried it, the <textarea> won't clear. Here's my code:
<textarea id="input_str"></textarea>
<button id="clear" type="button" py-onClick="clear">Clear</button>
...
<py-script>
code_input = Element("input_str")
def clear(*args, **kwargs):
code_input.clear()
</py-script> It looks like pys-onClick was deprecated in favor of py-onClick per an error I received while troubleshooting. There aren't many resources out there so I'm stuck. Would anyone point me in the right direction?
3
Upvotes
View all comments
Show parent comment
2
u/[deleted] Oct 21 '22
You rock. The
clearfunction is now working. On to the other functions!