jQuery merupakan salah satu framework javascript yang sangat terkenal dan untuk menggunakannya anda bisa mendownload scriptnya dan memasangkannya pada website anda. Selain mendownload anda juga bisa menggunakan jQuery melalui CDN hosted berikut ini:
- Google Ajax API CDN
- Microsoft CDN
- jQuery CDN (via Media Temple)
- http://code.jquery.com/jquery-1.5.2.min.js (Minified version)
- http://code.jquery.com/jquery-1.5.2.js (Source version)
Selanjutnya adalah contoh penggunaan jQuery pada halaman website dengan memasukkan script jQuery ke dalam direktori website.
<html>
<head>
<title>Hello jQuery</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"
src="jquery/jquery-1.5.2.js" ></script>
<script type="text/javascript">
$(document).ready(
function(){
$("a").click(
function(){
alert("Hello World");
}
);
}
);
</script>
</head>
<body>
<a href="http://jquery.com">JQuery Website</a>
</body>
</html>
Contoh penggunaan jQuery yang lainnya adalah melalui CDN seperti yang telah dibahas diatas, adalah seperti berikut:
<html>
<head>
<title>Hello jQuery</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js" ></script>
<script type="text/javascript">
$(document).ready(
function(){
$("a").click(
function(){
alert("Hello World");
}
);
}
);
</script>
</head>
<body>
<a href="http://jquery.com">JQuery Website</a>
</body>
</html>
Hasil dari 2 script diatas dapat diliat disini. Perlu diketahui demo yang saya berikan tersebut menggunakan jQuery melalui CDN google.
Comments