jQuery Getting Started

"jQuery is a fast, small, and feature-rich JavaScript library."

1.Google CDN

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>

2.jQuery Syntax

$(document).ready(function(){
    $("p").click(function(){
        $(this).hide();
    });
});

3. jQuery selector

3.1 Element selector

$("p")
$("button")

3.2 ID selector

$("#id")

3.3 class selector

$(".class")

4. DOM Events

Mouse EventsKeyboard EventsForm EventsDocument/Window Events
clickkeypresssubmitload
dblclickkeydownchangeresize
mouseenterkeyupfocusscroll
mouseleave blurunload

5. on() Method

The on() method attaches one or more event handlers for the selected elements.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("p").on({
        mouseenter: function(){
            $(this).css("background-color", "lightgray");
        },  
        mouseleave: function(){
            $(this).css("background-color", "lightblue");
        }, 
        click: function(){
            $(this).css("background-color", "yellow");
        }  
    });
});
</script>


6.  jQuery Effect Methods

MethodDescription
animate()Runs a custom animation on the selected elements
clearQueue()Removes all remaining queued functions from the selected elements
delay()Sets a delay for all queued functions on the selected elements
dequeue()Removes the next function from the queue, and then executes the function
fadeIn()Fades in the selected elements
fadeOut()Fades out the selected elements
fadeTo()Fades in/out the selected elements to a given opacity
fadeToggle()Toggles between the fadeIn() and fadeOut() methods
finish()Stops, removes and completes all queued animations for the selected elements
hide()Hides the selected elements
queue()Shows the queued functions on the selected elements
show()Shows the selected elements
slideDown()Slides-down (shows) the selected elements
slideToggle()Toggles between the slideUp() and slideDown() methods
slideUp()Slides-up (hides) the selected elements
stop()Stops the currently running animation for the selected elements
toggle()Toggles between the hide() and show() methods


Reference:  http://www.w3schools.com/jquery/jquery_events.asp

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值