0

I feel really silly asking this, but it is completely blowing my mind why my link to the Google jQuery api isn't working. I know my code isn't broken because it works here: http://jsfiddle.net/jefffabiny/8p46d/

Here are my script tags in my index file:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="js/functions.js"></script>

Other than that, the doctype is HTML5, and I'm working on an local xampp install. I bet I over looked something small; does anyone see the problem here? Thanks.

EDIT Actually, after I submitted this post I got an alert at the top of my browser saying stack overflow requires javascript from an external domain to run properly, but it was being blocked. I guess that's my problem, but does anyone know how to fix that?

4

1 回答 1

5

Are you executing your code after DOM is ready? jsFiddle does!

Try this:

$(function() {
    $('.test').on("click", function(){
        $(this).css('color', 'blue');
    });​
});
于 2012-06-22T13:28:08.527 回答