Monday, September 24, 2012

jquery/javascript - where should I put my script code?


put jquery code in body or head?


You should probably put your code right at the end of the body tag.
If you have multiple script includes and need to convince yourself that they will load in the correct order for you, check out WebSiteOptimization.com's Article on the Defer Attribute, where you can see the order your scripts execute.





It is because the link is after your Javascript. Move the link above it/javascript below the link and it should work fine. It's trying to select an element that doesn't yet exist.

EDIT: Aah you fixed it, spot on

No comments:

Post a Comment