Home > Web Front-end > JS Tutorial > body text

JQuery binding events, removal events and animations

巴扎黑
Release: 2017-06-30 11:37:02
Original
1371 people have browsed it


BindingEvent: bind(), on(), live(), delegate(), keyup();
Trigger event: trigger( 'keyup'), keyup();
Unbinding events: unbind(), off(), die(), undelegate();
Conforming events: hover(), toggle();
Events Binding: bind();


JQuery binding events, removal events and animations

##1. Binding event

​​

JQueryBinding events, in addition to the bing() method, there are also on(), live(), one( ) Binding methods for other events.

Binding event classification:

(a) Binding a single event

$("#btn").bind("click",function(){
    //代码块
    console.log(123);
});
Copy after login
Copy after login

(b) Binding multiple events at the same time

$("#btn").bind({
    mouseover:function(){
        $(this).css("background","red");
        console.log("代码块1");
    },
    mouseout:function(){
        console.log("代码块2");
    },
    click:function(){
        console.log("点击事件");
    }
});
Copy after login
Copy after login

For the differences between bind(), live(), and delegate() event methods in JQuery, please check:

http://www.php100.com/html/program/jquery/2013/0905/5993. html



2. Remove event

(a) Use the unbind() method to remove the event

  $("button").click(function(){
    $("p").unbind();
  });
Copy after login
Copy after login

3. JQueryAnimation

In Jquery, a series of methods for displaying animation effects are provided, among which,

  1. show() ——— Method controls the display of elements;

  2. hide() — ——-Method to control the display of elements;

  3. toggle() ——-Method to switch the visiblestate of elements;

  4. fadeIn() ——-Method fade in;

  5. fadeOut() ——Method fade out;

  6. slideUp()——Method to realize the shrinkage of elements

  7. slideDown()——Method Implement the expansion of elements


##Binding events: bind(), on(), live(), delegate(), keyup();
Trigger events: trigger('keyup'), keyup();

Unbinding events: unbind(), off(), die(), undelegate();
Conforming events: hover(), toggle ();
Event binding: bind();


JQuery binding events, removal events and animations

##1. Binding events

JQuery binding events, in addition to the bing()

method, there are also

on(), live(), one () Binding methods for and other events.
Binding event classification:

(a) Binding a single event

$("#btn").bind("click",function(){
    //代码块
    console.log(123);
});
Copy after login
Copy after login

(b) Binding multiple events at the same time

$("#btn").bind({
    mouseover:function(){
        $(this).css("background","red");
        console.log("代码块1");
    },
    mouseout:function(){
        console.log("代码块2");
    },
    click:function(){
        console.log("点击事件");
    }
});
Copy after login
Copy after login

For the differences between bind(), live(), and delegate() event methods in JQuery, please check:

http://www.php100.com/html/program/jquery/2013/0905/5993. html


2. Remove the event

(a) Use the unbind() method to remove the event

  $("button").click(function(){
    $("p").unbind();
  });
Copy after login
Copy after login
3. JQuery animation

In Jquery, a series of methods for displaying animation effects are provided, among which,

    show()
  1. ——— Method controls the display of elements;

  2. hide()
  3. ——— Method controls the display of elements;

  4. toggle()
  5. ——-Method switches the visible state of the element;

  6. fadeIn()
  7. — ——Method fade in;

  8. fadeOut()
  9. ——Method fade out;

    ##slideUp()
  10. ——Method to realize the shrinking of elements
  11. slideDown()
  12. ——Method to realize the expansion of elements

The above is the detailed content of JQuery binding events, removal events and animations. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template