Launching Code on Document Ready
by 蘇德宙, 2010-04-08 18:55, 人氣(1761)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="jquery.js"></script>
<script>
$(document).ready(
function() {
$("a").click(
function(event) {
alert("prevent the default behaviour");
event.preventDefault();
}
);
}
);
</script>
</head>
<body>
<a href="jQueryhttp://jquery.com/">jQuery</a>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="jquery.js"></script>
<script>
$(document).ready(
function() {
$("a").click(
function(event) {
alert("prevent the default behaviour");
event.preventDefault();
}
);
}
);
</script>
</head>
<body>
<a href="jQueryhttp://jquery.com/">jQuery</a>
</body>
</html>
[demo]