J Query
J Query
J Query
jQuery
<head>
<script src="jquery-1.10.2.min.js"></script>
</head>
jQuery
Jquery Syntax :
$(document).ready(function(){
// jQuery method ketik disini...
});
atau
$(function(){
// jQuery method ketik disini...
});
jQuery
Example :
….
<head>
<script src="jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>Click untuk sembunyi</p>
<p>Click juga untuk sembunyi</p>
</body>
jQuery
Jquery Selectors :
Berfungsi untuk memanipulasi element-
element HTML
1. Element Selector
2. Id Selector
3. Class Selector
4. CSS Selector
5. Atribut Selector
jQuery
1. Elemen Selectors
Berfungsi untuk memanipulasi tag-tag HTML
1. Hide/Show
2. Fade
3. Slide
4. Animate
5. Stop
jQuery
1. Hide/Show :
<!DOCTYPE html> <body>
<html> <p>Klik Button.</p>
<head> <button id="hide">
<script src="jquery-1.10.2.min.js"></script> Hide
<script> </button>
$(document).ready(function(){ <button id="show">
$("#hide").click(function(){
$("p").hide(1000);
Show
}); </button>
$("#show").click(function(){ </body>
$("p").show(1000); </html>
});
});
</script>
</head>
jQuery
1. Hide/Show (Lanjutan):
<!DOCTYPE html> <body>
<div id="menu1">Menu 1</div>
<html> <div class="submenu1">Sub Menu 1.1</div>
<head> <div class="submenu1">Sub Menu 1.2</div>