JQuery知识点总结

jQuery

核心方法

  • $(): 
    参数如果是字符串,此字符串代表选择器 
    参数是JS原生对象,将其转变为jQuery对象 
    参数是一个方法,就是执行document.ready()

  • each():将jQuery选择的元素循环遍历

1
$("img").each(function(){
2
  $(this).toggleClass("example");
3
});
  • 注册一个jQuery Plugin
1
    jQuery.fn.extend({
2
        abc : function() {
3
            return this.each(function() {
4
                // 核心的处理代码
5
                $(this).val($(this).val() + "abc");
6
            });
7
        }
8
    });

jQuery选择器

  • ID #
  • Class .
  • 标签 标签名
  • find('选择器') 在一定的DOM范围中选择

属性方法

  • attr() : 设置DOM属性
1
$("a1").attr("href","www.qq.com");
  • addClass() : 添加样式
  • html() :
1
$("#adiv").html("<input type='button' value='btn'/>"); // 添加一个按钮
2
$("#adiv").html(); // 取出adiv中的html代码,返回字符串
  • text() : 只是纯文本,不会解析为html

  • val() : 取表单元素的值,比如input select…

样式处理

css(style, value)

文档方法

append() 
appendTo() 
after() 
before() 
insertAfter() 
insertBefore() 
replaceWith() 
replaceAll() 
empty() 
remove() 
clone()

筛选方法

eq() 
hasClass() 
children() 
find() 
parent()

事件

ready() 
on() : 通用的时间处理函数 
blur() : 失去焦点时间 
click() 
change():最多用于select元素

效果

show() 
hide() 
toggle()

[========]

AJAX

  • 理解同步和异步的概念
  • 理解回调函数的概念
1
    var i = 0;
2
3
    var timer = setInterval(function(){
4
        $(".color").hide();
5
        $(".color").eq(i).show();
6
        i++;
7
        if (i == $(".color").length) i = 0;
8
    },1000);
9
10
    var t = 0;
11
    $.ajax({
12
        url:"http://localhost:8080/Review/test",
13
        success:function(rs){
14
            t = 1;
15
            console.log(rs);
16
            console.log("t in success = " + t);
17
        } 
18
    })
19
20
    console.log("t outside  = " + t);

使用原生的JS进行DOM操作相对较少,在JS的框架中,jQuery和ExtJS(Apple,自成体系)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值