
Yes,we could achieve this in SharePoint Online.
My test result:
14439-requirement.txt
14643-requirement2.txt
You could get my test code in attachments. The requirement.txt is the jQuery version, the requirement2.txt is the JavaScript version.
Tip: Please remember to remove the first and last comment tags.