java學習

          java學習

           

          jquery事件類型

          添加css樣式

          <html>
          <head>
            <style>
            .over{
            color:red;
            background:#888;
            }
            </style>
           <script src="../../scripts/jquery-1.3.1.js" type="text/javascript"></script>
            <script type="text/javascript">
            $(function(){
               $("div").bind("mouseover mouseout", function(){
                  $(this).toggleClass("over");
               });
            })
            </script>
          </head>
          <body>
          <div style="width:100px;height:50px;">滑入.</div>
          </body>
          </html>

          根據事件類型
          <html>
          <head>
            <script src="../../scripts/jquery-1.3.1.js" type="text/javascript"></script>
            <script type="text/javascript">
            $(function(){
              $("div").bind("click.plugin",function(){
                     $("body").append("<p>click事件</p>");
              });
              $("div").bind("mouseover.plugin", function(){
                     $("body").append("<p>mouseover事件</p>");
              });
              $("div").bind("dblclick", function(){
                     $("body").append("<p>dblclick事件</p>");
              });
              $("button").click(function() {
                  $("div").unbind(".plugin");  
              })
            })
            </script>
          </head>
          <body>
          <div style="width:100px;height:50px;background:#888;color:white;">test.</div>
          <button >根據命名空間,刪除事件</button>
          </body>
          </html>

          相同事件名稱,不同命名空間執行方法

          <html>
          <head>
            <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后面的感嘆號
              });
            })
            </script>
          </head>
          <body>
          <div style="width:100px;height:50px;background:#888;color:white;">test.</div>
          <button >根據命名空間,觸發事件</button>
          </body>
          </html>

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


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


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 沁水县| 麻城市| 大悟县| 寻乌县| 溆浦县| 新巴尔虎右旗| 霍山县| 宜君县| 淮安市| 原阳县| 元谋县| 哈巴河县| 霞浦县| 福鼎市| 池州市| 微山县| 西平县| 宁化县| 邯郸市| 镇沅| 榆中县| 庆阳市| 康马县| 辰溪县| 岱山县| 读书| 仁寿县| 右玉县| 河源市| 镇赉县| 南充市| 齐齐哈尔市| 满城县| 连城县| 天柱县| 柯坪县| 大田县| 宣城市| 福鼎市| 灵宝市| 高密市|