java學習

          java學習

           

          jquery自定義事件

          <html>
          <head>
          <style type="text/css">
          *{margin:0;padding:0;}    
          body { font-size: 13px; line-height: 130%; padding: 60px; }
          p {width:200px;background:#888;color:white;height:16px;}
          </style>
          <script src="../../scripts/jquery-1.3.1.js" type="text/javascript"></script>
          <script type="text/javascript">
              $(function(){
                 $('#btn').bind("myClick", function(){
                               $('#test').append("<p>我的自定義事件.</p>");
                        });
                 $('#btn').click(function(){
                      $(this).trigger("myClick");
                 }).trigger("myClick");
              })
          </script>
          </head>
          <body>
          <button id="btn">點擊我</button>
          <div id="test"></div>
          </body>
          </html>

          <html>
          <title></title>
          <style type="text/css">
          *{margin:0;padding:0;}    
          body { font-size: 13px; line-height: 130%; padding: 60px; }
          p {width:200px;background:#888;color:white;height:16px;}
          </style>
          <script src="../../scripts/jquery-1.3.1.js" type="text/javascript"></script>
          <script type="text/javascript">
              $(function(){
                  $('#old').bind("click", function(){
                      $("input").trigger("focus");
                  });
                  $('#new').bind("click", function(){
                      $("input").triggerHandler("focus");
                  });
                  $("input").focus(function(){
                      $("body").append("<p>focus.</p>");
                  })
              })
          </script>
          </head>
          <body>
          <button id="old">trigger</button>
          <button id="new">triggerHandler</button>
          <input />
          </body>
          </html>

          posted on 2013-03-19 14:01 楊軍威 閱讀(203) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 搜索| 凌海市| 修水县| 刚察县| 宁安市| 平湖市| 汉川市| 平乐县| 永顺县| 新乐市| 龙陵县| 资源县| 新和县| 苏州市| 陵川县| 海门市| 珲春市| 塘沽区| 沽源县| 沧源| 思茅市| 成都市| 沂源县| 大名县| 原阳县| 连南| 沂水县| 嘉义市| 界首市| 瓮安县| 沿河| 莱西市| 安化县| 靖远县| 新竹市| 光泽县| 蒙城县| 阜宁县| 松滋市| 东明县| 黄龙县|