Script problem "TypeError: $ is not a function"

I have a script on some pages, works in plain html, but give error in Revo:
script

$(document).ready(function(){
$(“#show2”).click(function(){
$(“#bekræftet”).show();
$(“#bekræft”).hide();
});
});
/script

Error is: TypeError: $ is not a function
What gives?

1 Like

I think you need the opening code of something like this <?

Here’s a sample of a simple php code in a snippet in Modx

<?php
return 'Hello, World!';
?>

it is js script, not php

I have < script > - - - < /script > (without the empty spaces)

but it would not show in the post (therefore spaces this time).

1 Like

Ah yes, to post code you can put three single ticks ticks above and below the code

Do you have the script in your section or in your footer? That’s where they should go…

I have the script at top of ‘content’ in a ‘resource’ (page).
Actually I fixed it by adding this script:
< script src=“https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”>< /script>

  • apparently jquery.min could not be found in assets.

& where is the tick symbol on my keyboard anyway?

1 Like

Ah ok yeah, you have to link to the jquery file, either on another site or a local link to assets

For me the single tick is all the way at top left on my keyboard, right next to the number 1

There was an obscure ‘inherited’ internal link, but that apparently did not point in the right direction. (inherited from a drupal 8 site).
My keyboard is Danish so I don’t know - anyway we figured it out.

1 Like

Yup, good job troubleshooting. I wish they would put the three ticks rule on the front page, but…