Javascript code not working – $ is not a function error

I actually just wanted to make a comment but..(reputation is too low) so doing it this way.

If for some reason two versions of jQuery are loaded (which is not recommended), calling $.noConflict( true ) from the second version will return the globally scoped jQuery variables to those of the first version.

So to solve your ‘issue’ (if I am correct) the solution could be to put jQuery into the noConflict mode.

Click the link and read to see if my answer is correct and will solve your problem (by handing you the correct way for ‘how to do/use’).
jQuery, write less, do
more.