Wondering how to add a custom jQuery script to your magento 2 phtml template files?
You will above to include the javascript code inside a require
function. Here is how:
<script> require(['jquery', 'jquery/ui'], function($){ //your js code here. Use $ to access the jQuery library }); </script>
That is it! Simple 🙂