java學(xué)習(xí)

          java學(xué)習(xí)

           

          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>

          根據(jù)事件類型
          <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 >根據(jù)命名空間,刪除事件</button>
          </body>
          </html>

          相同事件名稱,不同命名空間執(zhí)行方法

          <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 >根據(jù)命名空間,觸發(fā)事件</button>
          </body>
          </html>

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


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


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 大丰市| 清徐县| 怀仁县| 灵武市| 鄂尔多斯市| 靖西县| 青阳县| 马公市| 松潘县| 云南省| 肃北| 阜南县| 舟山市| 罗定市| 阳新县| 电白县| 平武县| 广饶县| 新巴尔虎左旗| 澄城县| 廉江市| 阳信县| 砀山县| 久治县| 安多县| 南昌县| 化隆| 原阳县| 新闻| 大英县| 家居| 穆棱市| 广南县| 财经| 张家港市| 东兴市| 太白县| 温宿县| 霍州市| 滨海县| 北宁市|