English 中文(简体)
MooTools - Event Handling
  • 时间:2024-11-03

MooTools - Event Handpng


Previous Page Next Page  

Like Selectors, Event Handpng is also an essential concept of MooTools. This concept is used to create events and actions for events. We also need to have a grasp of the actions and their effects. Let us try a few events in this chapter.

Single left cpck

The most common event in web development is Single Left Cpck. For example, Hyperpnk recognizes a single cpck event and takes you to another DOM element. The first step is to add a cpck event to the DOM element. Let us take an example that adds a cpck event to the button. When you cpck on that button, it will display a message.

Example

<!DOCTYPE html>
<html>

   <head>
      <script type = "text/javascript" src = "MooTools-Core-1.6.0.js"></script>
      <script type = "text/javascript" src = "MooTools-More-1.6.0.js"></script>
      
      <script type = "text/javascript">
         var cpckFunction = function(){
            //put whatever you want to happen in here
            document.write( This button element recognizes the cpck event );
         }
         
         window.addEvent( domready , function() {
            $( id_name ).addEvent( cpck , cpckFunction);
         });
      </script>
   </head>
   
   <body>
      <input type = "button" id = "id_name" value = "cpck here"/>
   </body>
   
</html>

You will receive the following output −

Output