tags:

views:

122

answers:

3
+1  A: 

Do you have that script after the html has loaded?

If not, put it inside this tag

$(document).ready(function() {
   // put all your jQuery goodness in here.
 });

The script could probably be executing before the HTML has loaded, hence the error.

Dhana
+1  A: 

The $('hello') selector matches on an element with a name of hello, $('#hello') would match on an element with an id of hello. Could you have mistakenly named the element instead of applying the id?

lucas
+2  A: 

Could it be that you (or some component) is adding the Prototype library to your page? In Prototype, you select by ID using $('id') rather than $('#id'). Also, Prototype's $() function will return null if it doesn't find a match, while jQuery's $() function will never return null.

If Prototype (or another library with a $() function) is being loaded after jQuery, it would stomp all over jQuery's version of the $() function.

If it turns out this is the case, and you can't avoid using both jQuery and the other library, you'll probably want to take advantage of jQuery.noConflict.

Joel Mueller
Helped me solve my problem. Thank you! +1
LymanZerga