Solution:
First make sure that jquery is loaded on your page. Put this in your functions.php.
add_action('wp_enqueue_scripts', 'enqueue_my_files');
function enqueue_my_files(){
wp_enqueue_script('jquery');
}
And in your javascript section, use this syntax to define $ and then write your jquery code inside it
jQuery(document).ready( function($){
// you could put your jquery code in here!
});