JQuery event Overview (4)

Source: Internet
Author: User
Tags getscript

JQuery event Daquan attribute: [html] $ ("p "). addclass (style type defined in css) adds a style to an element $ ("img "). attr ({src: "test.jpg" alt: "test image"}) adds the attribute/value parameter map $ ("img") to an element "). attr ("src" "test.jpg") adds an attribute/value to an element $ ("img "). attr ("title" function () {return this. src}) Add a property/value to an element $ ("element name" ).html () to obtain the content in the element (element text, etc) $ ("element name" ).html ("<B> new stuff </B>") set content for an element $ ("element name "). removeattr ("attribute name") deletes a specified attribute and its value for an element. $ ("Element name "). removeclass ("class") deletes a specified style for an element $ ("element name "). text () Get the text of this element $ ("element name "). text (value) sets the text value of this element to value $ ("element name "). toggleclass (class) When the element has a style in the parameter, cancel setting this style if it does not exist $ ("input element name "). val () gets the value of the input element $ ("input element name "). val (value) sets the value of the input element to value manipulation: [html] $ ("element name "). after (content) add content after the Matching Element $ ("element name "). append (content) inserts content as the content of the element to the end of the element $ ("element name "). appendto (content) Element $ ("element name") after content "). before (content) is opposite to the after method $ ("element name "). clone (Boolean expression) when the Boolean expression is true, the cloned element is treated as true (if no parameter exists) $ ("element name "). empty () sets the content of this element to null $ ("element name "). insertafter (content) inserts this element into content $ ("element name "). insertbefore (content) inserts this element before the content $ ("element "). prepend (content) places content as a part of the element at the beginning of the element $ ("element "). prependto (content) puts this element as a part of content at the beginning of content $ ("element "). remove () delete all specified elements $ ("element "). remove ("Exp") delete all elements containing exp $ ("element "). wrap ("html") uses html to enclose this element $ ("element "). wrap (element) uses an element to enclose the element traversing: [html] add (expr) add (html) add (elements) children (expr) contains (str) end () filter (expression) filter (filter) find (expr) is (expr) next (expr) not (el) not (expr) not (elems) parent (expr) parents (expr) prev (expr) siblings (expr) core: [html] $ (html ). appendto ("body") is equivalent to writing an html code in the body $ (elems) Get an element on the dom $ (function (){........}) Execute a function $ ("div> p" ).css ("border" 1px solid gray ") to find the subnode p of all div add style $ (" input: radio "document. forms [0]) Find all radio buttons in the first form on the current page $. extend (prop) prop is a jquery object example: jquery. extend ({min: function (a B) {return a <B? A: B} max: function (a B) {return a> B? A: B }}) jquery (expression [context]) --- $ (expression [context]) by default, $ () queries the dom elements in the current html document. Each (callback) uses every matching element as the context to execute a function [html] example: 1 $ ("span "). click (function) {$ ("li "). each (function () {$ (this ). toggleclass ("example")}) example: 2 $ ("button "). click (function () {$ ("div "). each (function (index domele) {// domele = this variable (domele).css ("backgroundcolor" "yellow") if ($ (this ). is ("# stop") {$ ("span "). text ("stopped at div index #" + index) return false }})} jquery e Vent: ready (fn) $ (document). ready () Note that there is no onload event in the body; otherwise, this function cannot be executed. On each page, many functions can be loaded and executed in the order of fn. Bind (type [data] fn) binds one or more event processor functions for a specific event that matches an element (such as click. Possible event attributes include: blur focus load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error one (type [data] fn) binds one or more event processor functions for a specific event (such as click) matching an element. The event handler function is executed only once on each object. Other rules are the same as those of the bind () function. [Html] trigger (type [data]) triggers certain events on each matching element. Triggerhandler (type [data]) This specific method will trigger a specific event on an element (specify an event type) at the same time, cancel the default action unbind ([type] [data]) of the browser to unbind this event and delete the Bound event from each matching element. $ ("P "). unbind () removes all bound events in all paragraphs $ ("p "). unbind ("click") removes the click Event hover (over out) over out in all paragraphs. This method triggers the specified first function when you move the cursor over a matching element. When the mouse moves out of this element, the specified second function is triggered. $ ("P "). hover (function () {$ (this ). addclass ("over")} function () {$ (this ). addclass ("out")}) toggle (fn) if a matching element is clicked, the specified first function is triggered. When the same element is clicked again, the specified second function is triggered. $ ("P "). toggle (function () {$ (this ). addclass ("selected")} function () {$ (this ). removeclass ("selected")}) element event list description Note: parameters of a function without parameters are optional fn. Jquery does not support reset events of form elements. Event Description supports element or object [html] blur () element loss focus a input textarea button select label map area change () user changes field content input textarea select click () click almost all elements of an object, dblclick (), double-click an object, and almost all elements, error (). An error occurs when a document or image is loaded. window img focus () element obtains focus a input textarea button select label map area keydown () keys of a keyboard are pressed by almost all elements keypress () keys of a keyboard are pressed or pressed by almost all elements keyup () A keyboard key is released. Almost all elements are loaded. load (fn) a page or image is loaded. window img mouse Down (fn) a mouse key is pressed by almost all elements mousemove (fn) the mouse is moved by almost all elements mouseout (fn) the mouse removes almost all elements from a certain element mouseover (fn) move the mouse over an element almost all elements mouseup (fn) a mouse button is released almost all elements resize (fn) window or frame is adjusted size window iframe frame scroll (fn) when you scroll down the visible part of a document, the window select () text is selected and the document input textarea submit () submit button is clicked. The form unload (fn) User exits the window jquery ajax method description on the page: [html] load (url [data] [callback]) loads a remote html content to a dom node. $ ("# Feeds "). load ("feeds.html") loads the feeds.html file into the div with the id of feeds $ ("# feeds "). load ("feeds. php "{limit: 25} function () {alert (" the last 25 entries in the feed have been loaded ")}) jquery. get (url [data] [callback]) uses get to request a page. $. Get ("test. cgi "{name:" john "time:" 2 "} function (data) {alert (" data loaded: "+ data)}) jquery. getjson (url [data] [callback]) uses get to request json data. $. Getjson ("test. js "{name:" john "time:" 2 "} function (json) {alert (" json data: "+ json. users [3]. name)}) jquery. getscript (url [callback]) uses get to request and execute javascript files. $. Getscript ("test. js "function () {alert (" script loaded and uted. ")}) jquery. post (url [data] [callback] [type]) uses post to request a page. Ajaxcomplete (callback) executes a function after an ajax request ends. This is an ajax event $ ("# msg "). ajaxcomplete (function (request settings) {$ (this ). append ("<li> request complete. </li> ")}) ajaxerror (callback) executes a function when an ajax request fails. This is an ajax event $ ("# msg "). ajaxerror (function (request settings) {$ (this ). append ("<li> error requesting page" + settings. url + "</li>")}) ajaxsend (callback) executes a function when an ajax request is sent. This is an ajax event $ ("# msg "). ajaxse... [html] method description bind () attaches one or more event processor blur () to the matching element to trigger, or binds the function to the blur event change () of the specified Element () trigger, or bind the function to the change event click () trigger of the specified element, or bind the function to the click Event dblclick () of the specified Element () trigger or bind the function to the double click event delegate () of the specified element to attach one or more event processor die () to the current or future child elements of the matching element () remove all event handlers added using the live () function. Error () is triggered, or the function is bound to the error event. isdefapreprevented () of the specified element to return whether event. preventDefault () is called on the event object (). The cursor position of event. pageX relative to the left edge of the document. The cursor position of event. pageY relative to the top edge of the document. Event. preventDefault () blocks the default action of an event. Event. result contains the last value returned by the event processor triggered by the specified event. Event.tar get the DOM element that triggers the event. Event. timeStamp this attribute returns the number of milliseconds from January 1, January 1, 1970 to when the event occurred. Event. type describes the event type. Event. which indicates which key or button is pressed. The focus () trigger, or bind the function to the keydown () trigger of the focus event of the specified element, or bind the function to the key down event keypress () of the specified element () trigger, or bind the function to the key press event keyup () of the specified element to trigger, or bind the function to the key up event live () of the specified element () add one or more event processor load () triggers for the current or future matching element, or bind the function to the specified Element's load event mousedown () trigger, bind the function to the mouse down event mouseenter () of the specified element to trigger, or bind the function to the mouse enter event mouseleave () of the specified element () trigger, or bind the function to the mouse leave event mousemove () of the specified element to trigger, or bind the function to the mouse move event mouseout () of the specified element to trigger, or bind the function The mouse out event mouseover () of the specified element is triggered, or the function is bound to the mouse over event mouseup () of the specified element () trigger or bind the function to the mouse up event one () of the specified element to add an event processor to the matching element. Each element can only trigger this processor once. Ready () Document readiness event (when the HTML document is ready for use) resize () trigger, or bind the function to the resize event scroll () of the specified Element () trigger, or bind the function to the scroll event of the specified element to trigger, or bind the function to the select event submit () of the specified element () trigger or bind the function to the toggle () submit event of the specified element to bind two or more event processor functions, which are executed in turn when a click event occurs. Trigger () All specified events that match the element triggerHandler () The first specified event unbind () of the matched element removes an added event processor undelegate () from the Matching Element () remove an added event processor from the Matching Element, trigger unload () now or in the future, or bind the function to the unload event of the specified element.

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.