We could use document.getElementById(id) to get the target element.And you could take a reference to add event listener for button click:https://social.technet.microsoft.com/wiki/contents/articles/53182.spfx-webpart-how-to-add-event-listener-for-button-click.aspx
My test code for your reference:63865-code.txt
Test result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.