posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          jquery 學(xué)習(xí)筆記_1

          Posted on 2007-11-08 17:12 G_G 閱讀(491) 評論(1)  編輯  收藏 所屬分類: javascript Framework
          參考:
          ??? http://visualjquery.com/1.1.2.html

          1.定位
          $(?'xx'?)
            $("p[a]").hide();
          $("p:eq(0)").show();
          $("div:visible").hide();
          $("ul/li")
          /* valid too: $("ul > li") */
          $("p.foo[a]");
          $("input[@name=bar]").val();
          $("input[@type=radio][@checked]")


          2.事件添加
          ?? <a href="#" name="li" >Link</a>

          ?? $(document).ready(
          function()?{
          ???????? $(
          "a").click(function()?{????????????????????
          ?????????????? $("div").hide(); //跌代不可見 <a>

          ????? });
          ??? });

          3.頁面 javascript 輸入(和jsp的 out.print(...))$(html)
          $("<div?id='div1'><font?color='red''>Hello</font></div>").appendTo("body");

          4.寫css
          $(document.body).css(?"background",?"black"?);

          5.包含定位
          <p>one</p> <div><p>two</p></div> <div>three</div>

          $(
          "div?>?p") //定位two <p>two</p>

          6.范圍定位
          <body>
          ????????
          <form>
          ????????????
          <input?type="button"?value="哈哈"/>
          ????????
          </form>
          </body>

          $("input:button",?document.forms[0])[0].setAttribute("value","google");
          ? $("div", xml.responseXML) 等

          7.表達試定位
          $("p[@name='p1']").hide();//hide不要?$(..)[0]

          $("input[@name='butt1']:button",?document.forms[0])[0].setAttribute("value","google");

          8.$(..).fun.. 添加方法
          ????????<form>
          ????????????
          <input?name="butt1"?type="button"?value="google"/>
          ????????
          </form>
          ????????
          <script>
          ????????????????
          ????????jQuery.fn.extend({
          ??????????check:?
          function()?{
          ????????????alert('check');
          ??????????}
          ????????});
          ????????$(
          "input[@name='butt1']:button",?document.forms[0]).check();
          ????????
          </script>


          jQuery.extend({
          min: function(a, b) { return a < b ? a : b; },
          max: function(a, b) { return a > b ? a : b; }
          });


          9.
          $.noConflict()
          ????<body>
          ????????
          <form>
          ????????????
          <input?name="butt1"?type="button"?value="google"/>
          ????????
          </form>
          ????????
          <a?href="#"?temp_href="#"?name="li"?>Link</a>
          ????????
          <script>
          ????????????????
          ?????
          var?$j?=?jQuery.noConflict();??
          ???????
          ?????
          //?Use?jQuery?via?$j()??
          ?????$j(document).ready(function(){??
          ????????$(
          "a").click(function()?{???
          ???????????????$j(document.forms[
          0]).hide();??
          ???????????});
          ?????});?
          ????????
          </script>
          ????
          </body>

          10. $ 一般方法
          //each(fn)
          $("img").each(function(i){
          ??this.src?=?"test"?+?i?+?".jpg";
          });
          <img/><img/>
          <img?src="test0.jpg"/><img?src="test1.jpg"/>


          $("p").eq(1) //后1個
          $("p").lt(1) //正取 1 開始

          $("img").get();//全取
          $("img").get(0); //順序取 0開始
          $("p").gt(0) //反取從0開始

          $("*").index( $('#foo')[0] )
          <div id="foobar"><b></b><span id="foo"></span></div>
          返回結(jié)果 2

          $("img").length; //總長度
          $("img").size();








          評論

          # re: jquery 學(xué)習(xí)筆記_1  回復(fù)  更多評論   

          2009-05-09 17:59 by 王儉
          日歷的顯示有問題!
          主站蜘蛛池模板: 山东省| 安吉县| 彰武县| 双牌县| 门源| 琼海市| 古田县| 齐河县| 忻州市| 富锦市| 凤山市| 榆林市| 雷州市| 榕江县| 嘉兴市| 平顺县| 绥江县| 北安市| 黔江区| 江源县| 德阳市| 繁峙县| 汕尾市| 祁连县| 洪洞县| 鄱阳县| 寿光市| 化州市| 锦屏县| 洪江市| 双牌县| 莱州市| 景德镇市| 上蔡县| 思茅市| 商河县| 洪泽县| 务川| 揭东县| 南和县| 剑川县|