Events/bind bind( type, [data], fn ) JQuery


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="../jquery-latest.js"></script>
 
  <script>
  $(document).ready(function(){
  
    $("p").bind("click", function(e){
      var str = "( " + e.pageX + ", " + e.pageY + " )";
      $("span").text("Click happened! " + str);
    });
    $("p").bind("dblclick", function(){
      $("span").text("Double-click happened in " + this.tagName);
    });

  });
  </script>
  <style>
  p { background:yellow; font-weight:bold; cursor:pointer;
      padding:5px; }
  span { color:red; }
  </style>
</head>
<body>
  <p>Click or double click here.</p>
  <span></span>
</body>
</html>

2 comments:

Anonymous said...

ini script menampilkan apa mbaknya?????

Dewi Mulyani said...

sebagai event handler jika terjadi false pada event klik. CMIIW ^^