Jquery trigger event

Source: Internet
Author: User
<Form action = "" method = "get" id = "form1"> <input type = "text" id = "text1" value = "ABC"/> <input type = "button" id = "button1" value = "button"/>   <input type = "Submit" value = "Submit"/> </form> <a href = "http://www.126.com"> link </a> <SCRIPT type = "text/JavaScript" src = "jquery-1.8.2.js"> </SCRIPT> <SCRIPT type = "text/JavaScript" Defer> // ========== === jquery does not support F The reset event of the orm element. $ ("# Text1 "). blur (function () {// ==================== element loss of focus (non-mouse removal from the element) A, input, textarea, button, select, label, MAP, area // alert ("Blur") ;}); $ ("# text1 "). change (function () {// =================== the user changes the value of the field input, textarea, select // alert ("change") ;}; $ ("# button1 "). click (function () {// ================== click the left mouse button to almost all elements of an object // alert ("click ");}); $ ("# button1 "). dblclick (function () {// ================== left mouse button to quickly double-click almost all elements of an object // alert ("dblc Lick ") ;}); $ (" # img1 "). error (function () {// ================== when an element encounters an error (not properly loaded), an error occurs. Window, IMG // alert ("error") ;}); $ ("# text1 "). focus (function () {// ==================== element obtains focus (not move the mouse over the element) A, input, textarea, button, select, label, MAP, area // alert ("Focus") ;}); $ ("# text1 "). keydown (function () {// ================== when the specified Element obtains the focus, when a keyboard key is pressed, almost all elements // alert ("keydown") ;}); $ ("# button1 "). keypress (function () {// ================== when the specified Element obtains the focus, A keyboard key is pressed or pressed to almost all elements // alert ("keypress") ;}); $ ("# button1 "). keyup (Function () {// ==================== When the specified Element obtains the focus, A keyboard key is released with almost all elements // alert ("keyup") ;}); $ ("# img2 "). load (function () {// ================= a page or image is loaded to the window, IMG // alert ("LOAD") ;}); $ ("# button1 "). mousedown (function () {// ================== move the mouse over the element and press any key to almost all elements // alert ("mousedown ");}); $ ("# button1 "). mouseenter (function () {// when the mouse pointer passes through an element, the mouseenter event occurs. Unlike the Mouseover event, when the mouse pointer passes through the selected element, only one mouseenter event is triggered whether or not the selected element passes through its Child element. // Alert ("mouseenter") ;}; $ ("# button1"). mouseleave (function () {// mouseleave event occurs when the mouse pointer leaves the element. Unlike the mouseout event, when the mouse pointer leaves the selected element, the mouseleave event is triggered only once, regardless of whether the child element is left or not. // Alert ("mouseleave") ;}); $ ("# text1 "). mousemove (function () {// ================== trigger almost all elements without stopping the mouse over the specified Element // alert ("mousemove ");} ); $ ("# button1 "). mouseout (function () {// ================== move the mouse away from the specified element, the mouseout event is triggered no matter the mouse pointer leaves the selected element or any child element. Almost all elements // alert ("mouseout") ;}); $ ("# button1 "). mouseover (function () {// ================== move the mouse over the specified element, regardless of whether the mouse pointer passes through the selected element or its child element, the Mouseover event is triggered. Almost all elements // alert ("Mouseover") ;}); $ ("# button1 "). mouseup (function () {// ==================== the mouse is released on a specified element by a mouse button almost all elements // alert ("mouseup ");} ); $ (window ). resize (function () {// ================== window or frame size adjusted window, IFRAME, frame // alert ("resize") ;}); $ (window ). scroll (function () {// ================== when the user scrolls the specified element, a scroll event occurs. The croll event applies to all elements and window objects that can be rolled (browser windows ). // Alert ("scroll") ;}; $ ("# text1 "). select (function () {// ================== any character selected for the text in the specified area triggers document, input, textarea // alert ("select") ;}); $ ("# form1 "). submit (function () {// ================== the submit button is clicked by form // alert ("Submit ");}); $ (window ). unload (function () {// ================== when the user leaves the page, the unload event will occur. Specifically, an unload event is triggered when: // alert ("Unload "); // ==================== click a link to leave the page, type a new URL in the address bar, and use the forward or backward button, close the browser and reload the page, but Google is not easy to use in the test}); $ ("# button1 "). BIND ('click dblclick Mouseover mouseout', function () {// ================== BIND () method to add one or more event handlers for the selected element and specify the function that runs when the event occurs. // Alert ("bind") ;}; $ ("# button1 "). one ("click", function () {// ================== attaches one or more event handlers to the selected element, and specify the function that runs when an event occurs. When the one () method is used, each element can only run an event processor function once. However, the test can only run once. // alert ("one") ;}); $ ("input "). live ("click", function () {// ================== attaches one or more event handlers to the selected element, and specify the function to run when these events occur. The event handler appended with the live () method applies to matching the current and future elements of the selector (such as new elements created by the script ). // Alert ("live") ;}); $ ("form "). delegate ("# button1", "click", function () {// =================== delegate () the method adds one or more event handlers to the child elements of the specified Element and specifies the function to run when these events occur. # Button1 is the child element of the specified Element // alert ("delegate") ;}); // $ ("input "). trigger ("select"); // ==================== specifies the event to be triggered by the selected element. // Not verified // $ ("input "). triggerhandler ("select"); // ================== triggerhandler () method triggers the specified event type of the selected element. However, it does not execute the default browser action or generate event bubbles. // Not verified // ===================== the triggerhandler () method is similar to the trigger () method. The difference is that it does not trigger the default behavior of events (such as form submission), and only affects the First Matching Element. // $ ("Input "). unbind (); // ================== unbind () method removes the event handler for the selected element. This method can remove all or selected event handlers, or terminate the running of the specified function when an event occurs. Ubind () applies to any event handler appended with jquery. // $ ("Input "). undelegate (); // ================== undelegate () method deletes one or more Event Handlers added by the delegate () method. // $ ("Input "). die (); // ==================== die () method to remove all () method to add one or more event handlers to a specified element. Not tested // =================================================== ========================================================== event parameter attributes $ ("# button1 "). mousemove (function (event) {// alert ("X:" + event. pagex + ", Y:" + event. pagey); // ==================== event. the pagex attribute is the cursor position, relative to the left edge of the document. The event. Pagey attribute is the cursor position, relative to the top edge of the document .}); $ (""). Click (function (event) {// event. preventdefault (); // ================== preventdefault () method to prevent elements from performing default behaviors (for example, when you click the submit button, the form cannot be submitted ). // Alert (event. isdefapreprevented (); // ================== isdefapreprevented () method returns whether preventdefault () is called on the specified event object () method .}); $ ("Input, IMG "). click (function (event) {// alert(event.tar get. nodename); // ==================== the DOM element returned by the target attribute to trigger the event. // Alert (this. nodename); // your desired parameter has the same effect as your desired parameter.}); $ ("# button1 "). click (function (event) {// event. result = "A"; // alert (event. result); // ==================== the result attribute contains the last value returned by the event processor triggered by the specified event, unless this value is not defined .}); $ ("# Button1"). Click (function (event) {// alert (event. timestamp); // The timestamp attribute contains the number of milliseconds from January 1, January 1, 1970 to when the event is triggered. Poor test}); $ ("# button1 "). BIND ('click dblclick Mouseover mouseout', function (event) {// alert (event. type); // The type attribute describes the event type to be triggered .}); $ ("Input"). keydown (function (event) {// alert (event. Which); // The which attribute indicates which key or button is pressed. The return value is a numeric value, but the return value of the same number on the keyboard is different from that on the keyboard. the return value should be the index value of the keyboard key}); </SCRIPT>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.