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

          jquery 學習筆記_1

          Posted on 2007-11-08 17:12 G_G 閱讀(498) 評論(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 王儉
          日歷的顯示有問題!
          主站蜘蛛池模板: 海盐县| 磐安县| 上高县| 房山区| 北安市| 南木林县| 达尔| 张家港市| 读书| 汾阳市| 麦盖提县| 贵港市| 温泉县| 泾源县| 白山市| 天津市| 手游| 甘洛县| 昭觉县| 越西县| 台山市| 桂阳县| 兰溪市| 大埔区| 金川县| 青浦区| 沙河市| 盈江县| 从化市| 吉林市| 江安县| 平遥县| 湖口县| 玉门市| 苏尼特左旗| 哈尔滨市| 大邑县| 民丰县| 台东县| 霍林郭勒市| 华宁县|