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)  編輯  收藏


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


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 即墨市| 崇阳县| 东莞市| 绍兴县| 灌阳县| 那坡县| 黄浦区| 石棉县| 邵阳市| 呼图壁县| 乌鲁木齐县| 襄樊市| 哈密市| 宿迁市| 庐江县| 阳新县| 嘉祥县| 化州市| 孟村| 常州市| 科技| 双城市| 军事| 留坝县| 勐海县| 平远县| 通化市| 普陀区| 弥勒县| 镇平县| 盐山县| 航空| 焦作市| 秀山| 怀宁县| 梓潼县| 青海省| 永春县| 枣庄市| 甘洛县| 昆明市|