Jquery in custom js

how to use jquery in custom js the correct way?
if i try to use $ in custom js code i get undefined. but in the browser console $ is working fine.

i know that jquery is loaded in the page by default

Hi @mohammad_altoiher

Perhaps the JQuery lib is not loaded when the custom code is running
could you please share a link to the test page with minimum UI/Logic just to see the issue?

the custom js code run on button click (i wait before clicking to make sure its loaded)
this is the error when i click on the button

Uncaught (in promise) ReferenceError: $ is not defined

here is the code


Hello @mohammad_altoiher,

how do you know that jQuery is loaded?
We do not load it by default (and we don’t use it in any way).
What you see in the browser’s console is not jQuery, $ is an alias for document.querySelector. It is available only in browser’s console.

when we use $ its known as the shortcut for jquery by us js users so i was confused

i get it now thank you