Where am I doing wrong in my theme menu?

Put the java script code in footer.php after wp_footer(); code like this

<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#primary_menu ul li").hover(function () {
    jQuery(this).find("ul").stop().slideToggle(400);
});

});

Remove the dolar sign is not compatible in WordPress in this case.