<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事件</p>");
 });
 $("div").bind("click.plugin", function(){
   $("body").append("<p>click.plugin事件</p>");
 });
 $("button").click(function() {
   $("div").trigger("click!"); // 注意click后面的感叹号
   // click! 后面有叹号,是调用没有任何命名空间的click事件
   // click 后面没有叹号,是调用所有click事件(不管是那个命名空间的)
   // click.plugin 是调用某个特定命名空间的click事件(本例中是plugin)
 });
 })
 </script>
</head>
<body>
<div style="width:100px;height:50px;background:#888;color:white;">test.</div>
<button >根据命名空间,触发事件</button>
</body>
</html>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2022-01-21
  • 2022-03-01
  • 2022-02-16
  • 2021-12-17
猜你喜欢
  • 2021-06-21
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2023-02-21
  • 2021-10-13
相关资源
相似解决方案