| <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Title> </title> <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> <Script src = ".../scripts/jquery-1.3.1.js" type = "text/javascript"> </script> <Script type = "text/javascript"> $ (Function (){ $ ("Div"). bind ("click", function (){ $ ("Body"). append ("<p> click event </p> "); }); $ ("Div"). bind ("click. plugin", function (){ $ ("Body"). append ("<p> click. plugin event </p> "); }); $ ("Button"). click (function (){ $ ("Div"). trigger ("click! "); // Note the exclamation point after clicking // Click! There is an exclamation point next to it, which calls a click event without any namespace. // There is no exclamation mark after the click. It is used to call all the click events (whether in that namespace) // Click. plugin is the click event that calls a specific namespace (in this example, plugin) }); }) </Script> </Head> <Body> <Div style = "width: 100px; height: 50px; background: #888; color: white;"> test. </div> <Button> trigger an event based on the namespace </button> </Body> </Html> |