Launching Code onDocument Ready
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Jquery Tutorials</title>
<script src="js/jquery-1.6.4.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
//alert("test");
$("a").click(function (event) {
alert("Thank you for visiting");
// can prevent to redirect to google.com
event.preventDefault();
});
});
</script>
</head>
<body>
<a href="http://www.google.com">Google</a>
</body>
</html>
Adding and Removing an HTML class
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Jquery Tutorials</title>
<style type="text/css">
a.test{font-weight:bold;}
</style>
<script src="js/jquery-1.6.4.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
// add the class
$("a").addClass("test");
// remove the class
//$("a").removeClass("test");
});
</script>
</head>
<body>
<a href="http://www.google.com">Google</a>
</body>
</html>
SpecialEffects
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Jquery Tutorials</title>
<script src="js/jquery-1.6.4.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
//alert("test");
$("a").click(function (event) {
event.preventDefault();
// slowly disappear
$(this).hide("slow");
});
});
</script>
</head>
<body>
<a href="http://www.google.com">Google</a>
</body>
</html>
Callbackand Functions
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Jquery Tutorials</title>
<script src="js/jquery-1.6.4.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
// fetch the requested HTML snippet
$.get('SpecialEffects.htm', function (data) {
//$('.result').html(data);
alert(data);
});
});
</script>
</head>
<body>
<a href="http://www.google.com">Google</a>
</body>
</html>