Just responding because it is a quiet time on the Forum, and I want to help keep the question alive.
The form of your statement is using the jQuery library that is missing.
You should either convert it to plain JavaScript, or also inject the JavasSript code to load the jQuery library.
It has been a while since I used Javascript and jQuery, but I am sure there is someone who knows.