Unexpected token illegal when using JS in hook

Hello. I’m trying to add the code to rtp_hook_end_post_content:

  

And then I got an error Uncaught Syntax Error: Unexpected Token ILLEGAL. But when I put the function to Chrome Console it works correctly.
What should I do to fix this?

Hello Irina,

I just checked your code on my localhost and its working fine on my end. Give this a try after deleting all the invisible characters (whitespace) around that it.

Thanks,

Thank you! The problem was that the code worked as widget but didn't worked as a hook. So I had to change single quotation marks to doubles like here:

So now it works well.

Glad to know its working fine.

Thanks for using rtPanel.

dfgdfgdfgdfgdfgdfg