Please see my comments to the Solution 1.
If your goal is to get rid of 3rd-party library like jQuery, you really need to write the alternative code by yourself. (This site is "for those who code".)
And it can be done via the some routine steps. First of all, jQuery, as well as all other JavaScript library, is always available in source code. So, these steps could be:
- Look at the code fragment and understand what the library does. For this purpose, address to the library documentation. In case of jQuery, the documentation is very detail and clear, readily available.
- In addition to the previous item, if something is not quite clear, create a single HTML+JavaScript project (just one file) to experiment with this part if API, to understand better what it does.
- Look at JavaScript documentation and, where required, to the HTML DOM documentation in part related to JavaScript access, and try to figure out how to implement the same functionality. My favorite source is documentation, very accurate and detailed, is MDN:
JavaScript | MDN[^],
JavaScript — Learning web development | MDN[^]. - As an alternative or in addition to the previous step: dig into the source code of the library and find out how the part of API in question is actually implemented.
- PROFIT! :-)
See also the last comment by ppolymorphe to his Solution 1.
Good luck.
—SA