I trying to get onclick work, but it does not... Here is my code:
HTML
While the accepted answer (using ready
) works, it's not best practice.
Best practice is to put your script
tags at the end of the document, just before the closing tag, note the comments below:
jQuery alert test
That way
The elements exist when your code runs
Downloading the external scripts doesn't hold up the display of your page
More in the YUI Best Practices for Speeding Up Your Web Site.