PEMROGRAMAN WEB
MODUL 7
JQUERY
LATIHAN
Latihan 1
a. Sorce Code
<!DOCTYPE html>
<html lang="en">
<head>
<title>latihan 1</title>
<script type="text/javascript" src="Jquery.js"></script>
<script type="text/javascript">
$("document").ready (function () {
alert ("selamat datang");
});
</script>
</head>
<body>
<h1>hello word</h1>
</body>
</html>
b. Hasil Eksekusi
Latihan 2
a. Sorce Code
<!DOCTYPE html>
<html>
<head>
<title>Latihan 2</title>
<script lang="javascript" src="Jquery.Js"></script>
<script lang="javascript">
$(document).ready(function () {
$("input").click(function () {
alert("hello jquery");
});
});
</script>
</head>
<body>
<input type="submit" value="click me"/>
</body>
</html>
b. Hasil Eksekusi
Latihan 3
a. Sorce Code
<!DOCTYPE html>
<html>
<head>
<title>Latihan 3</title>
<script type="text/javascript" src="Jquery.js"></script>
<script type="text/javascript">
$("document").ready(function () {
$("#p1").css("color","red");
});
</script>
</head>
<body>
<p id="p1"> ini isi paragraf 1</p>
<p id="p2"> ini isi paragraf 2</p>
</body>
</html>
b. Hasil Eksekusi
Latihan 4
a. Sorce code
<!DOCTYPE html>
<html >
<head>
<title>Latihan 4</title>
<script type="text/javascript" src="Jquery.js"></script>
<script type="text/javascript">
$("document").ready(function () {
$(".Mulai").click(function () {
$("#kotak").animate({left:300},"slow")
});
});
</script>
<style type="text/css">
#kotak{
position: relative;
width: 100px;
height: 100px;
background: red;
}
</style>
<title>Animasi dengan funsi animate</title>
</head>
<body>
<input type="submit" class="Mulai" value="Jalankan"/>
<div id="kotak"></div>
</body>
</html>
b. Hasil Eksekusi
TUGAS
Tugas 1
a. Sorce code
!DOCTYPE html>
<html >
<head>
<title>Tugas 1</title>
<script type="text/javascript" src="Jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn1").click(function(){
alert("Text: " + $("#test").text());
});
$("#btn2").click(function(){
alert("HTML: " + $("#test").html());
});
});
</script>
</head>
<body>
<button id="btn1">Text</button>
<button id="btn2">HTML</button>
</body>
</html>
b. Hasil eksekusi
Tugas 2
a. Sorce code
<!DOCTYPE html>
<html >
<head>
<title>Tugas 2</title>
<script type="text/javascript" src="Jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn1").click(function(){
$("#test1").text("ADUH LUPA");
});
$("#btn2").click(function(){
$("#test2").html("<b>ADUH EUY</b>");
});
$("#btn3").click(function(){
$("#test3").val("Dolly Duck");
});
});
</script>
</head>
<body>
<button id="btn1">Text</button>
<button id="btn2">HTML</button>
<button id="btn3">Val</button>
</body>
</html>
b. Hasil eksekusi
Tugas 3
a. Sorce code
<!DOCTYPE html>
<html lang="en">
<head>
<title>tugas 3</title>
<script type="text/javascript" src="Jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".tombol1").click(function(){
$("p").hide(1000);
});
$(".tombol2").click(function () {
$("p").show(1000);
});
});
</script>
</head>
<body>
<p>hello word</p>
<button class="tombol1">sembunyikan</button>
<button class="tombol2">tampilkan</button>
</body>
</html>
b. Hasil Eksekusi