Thursday, January 1, 2009

[jQuery] Noob Q. Can't get jQuery working

Ok, this is a noob questions. I'm using Wordpress and have the
following code.

In the header I add:
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/
js/jquery-1.2.6.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/
js/test.js"></script>


The test javascript contains:
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});

function msg(txt) {
alert(txt);
}

In my test php file I have:
<a href="#"> test A </a> <br />
<a href="#" onclick="msg('Hello world')">Test B</a>


Now, clicking Test B links dislays the 'Hello World' alert.
But nothing happends when I click Test A. Why is that?

No comments: