Well, the executeScript function executes in the context of the browser only. So whatever the current browser page has loaded, you can then access it inside executeScript’s function block.
In your case, it would appear the page doesn’t use jQuery, so it doesn’t know what $ is.