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

          jquery 學習筆記_1

          Posted on 2007-11-08 17:12 G_G 閱讀(493) 評論(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>
          返回結果 2

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








          評論

          # re: jquery 學習筆記_1  回復  更多評論   

          2009-05-09 17:59 by 王儉
          日歷的顯示有問題!
          主站蜘蛛池模板: 阜康市| 遂平县| 库尔勒市| 仁怀市| 陈巴尔虎旗| 海晏县| 乐亭县| 沙湾县| 宝坻区| 喜德县| 长武县| 仲巴县| 金阳县| 来安县| 隆化县| 蓬溪县| 新巴尔虎左旗| 吉林市| 聂拉木县| 庄河市| 阳东县| 同仁县| 五台县| 石狮市| 麻栗坡县| 喀喇沁旗| 古田县| 靖西县| 枝江市| 富民县| 兴海县| 武山县| 白山市| 灯塔市| 三门峡市| 庐江县| 麻栗坡县| 黑水县| 抚州市| 黄浦区| 祁连县|