What do you mean by ‘doesn’t work’? Are you seeing errors in your browser’s console, or is the problem that the script isn’t doing what you are wanting it to do? If you can give us more information about what you are trying to accomplish, someone here will be able to point you in the right direction.
You can get some information about using javascript in themes from these topics: