Hi anonymous user,
In my test, using Script Editor WebPart in SharePoint Wiki page and writing the code you provided in it, it has no issue.
To help you better ,can you provide detailed information or screenshots?
Thanks for your understanding and support.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.