jQuery
   1.特点:
   小巧
   功能强
   跨浏览器
   插件
   2.使用
    实际是js文件
    a)  复制js到WebRoot
    b)  页面<script src="jquery.js" charset=""></script>
   3.核心对象及常用方法和属性
     a)名称
     jQuery和$
     用$找出来的对象叫jQuery对象
     用document找出来的对象叫Dom对象
     b)dom和jquery对象转换
     jQuery对象.get(0) --->dom对象
     $(dom对象)--->jQuery对象
     c)jQuery对象方法
      .show() 显示
      .hide() 隐藏
      .toggle() 显示或隐藏切换
      $("div").hide();
      $("#myid").show();
      $(".myclass").show(100);
      .size() 找到多少个对象
      var n = $("div").size()
      文本框赋值(value)
      $("#myid").val(123);
      .val()取值
      层的内容.innerHTML/.innerText
      $("div").html() ;
      $("div").html(123);
      $("div").html("<input type=button>");
      $("div").text("<input type=button>");
      样式 document....style.color="red"
      $("div").css("color","red").css("font-size","18");
      $("div").css({color:"red","font-size":18});
      删除
      $("div").remove(); 删除所有div
      添加
      父加子: $("div").append("<input button>");
              $("div").append( $("#myid") );
      子加父
           $("input").appendTo(  $("div") );
      对象属性
        $("input").attr("checked",true);
      去首尾空格:
         $.trim(字符串)
$("div").each(  function(i,obj){}  );
$.post(url,function(x){});
$.post(url,{键:值},function(x){});
$.getJSON(url,function(x){//这里x已转成json了,不要用eval});
      克隆
        $("div").clone();
4. 选择器
    a) 类选择器
       <input type=text class="myclass">
       $(".myclass")     找多个
    b) id选择器  
       <input type=text )[0].options(3).text //取索引为3的option值

 

转载自:http://www.iteye.com/topic/857093

作者:yzz9i (DEMO都在该地址)

相关文章:

  • 2021-12-15
  • 2021-10-24
  • 2022-02-28
  • 2021-10-01
  • 2021-04-28
  • 2021-07-01
  • 2021-05-10
  • 2021-10-03
猜你喜欢
  • 2022-02-06
  • 2021-12-11
  • 2021-07-27
  • 2021-10-16
  • 2022-01-07
  • 2021-12-31
相关资源
相似解决方案