Hello Jquery!

所有文件:

其中:
custom.js:

jQuery(document).ready(function() {
	$("a").click(function(){
		alert("Hello Jquery!");
	});
});
mklin.html:
<html>
<head>
<title>Test Jquery Demos</title>
<script src="jquery.js" type="text/javascript"></script>
<script src="custom.js" type="text/javascript"></script>
</head>
<body>
<a id="say_hello" href="#">click me</a>
</body>
</html>
对custom.js的说明:
// $("a")是一个jQuery选择器(selector),在这里它选择所有的a标签.
// $是jQuery类的一个别名,因此$()构造了一个新的jQuery对象.
// 函数 click() 是这个jQuery对象的一个方法,
// 它绑定了一个单击事件到所有选中的标签(这里是所有的a标签),并在事件触发时执行了它所提供的alert方法.

posted @ 2010-08-05 15:38  MikeLin  阅读(211)  评论(0编辑  收藏  举报