Jquery bagian 15 Events .bind()


HTML (bind.html)

<!DOCTYPE html>
<html>
<head>
  <style>
.bind { color:red; }
.butt { color:blue; }
</style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <p class="bind">Custom event, menyimpan fungsi dengan bind !</p>
<button>Tombol ini menggunakan fungsi trigger</button>
<span style="display:none;" class="butt"></span>
<script>

$(".bind").bind("myCustomEvent", function(e, Nama, myValue){
$(this).text("Halo, " + Nama +"!");
$(".butt").stop().css("opacity", 1)
.text("Nama anda adalah = " + Nama)
.fadeIn(30).fadeOut(1000);
});
$("button").click(function () {
$(".bind").trigger("myCustomEvent", [ "Anonymous" ]);
});
</script>
</body>
</html>


Download File

Tidak ada komentar:

Posting Komentar

Leave a message