JavaScipt Code not working

Dear bb-theme

I put the following code snippet into “Code” --> “JavaSript”:

$("#nextbutton").keypress(function(event){
if(event.keyCode == 13){
$(’#next’).click();
}
});

Unfortunately it does not work. The browsers javasript console tells me:
Uncaught TypeError: $ is not a function

Do you have any idea what i’m doing wrong?

Thanks for helping.
Dominic

Hey Dominic,

That’s because the jQuery that comes with WP is in compatibility mode where $ won’t work so it doesn’t conflict with any other libraries using the same sign as well. You can change all instances of $ to jQuery and that should work. You can check the link below for more info. :slight_smile:
https://digwp.com/2011/09/using-instead-of-jquery-in-wordpress/

Ben