Sharp jQuery Reading Notes --- Ajax in jQuery -- load method, jquery --- jquery
The first Ajax example
Content of test. jsp:
Ajax in jQuery
1. load ()
The load () method is the most simple and commonly used Ajax method in jQuery
jquery Selector1. Basic SelectorThe basic selector is the most commonly used selector in jquery and the simplest selector, which finds DOM elements by element ID, class, and tag name. This is very important, the following content is based on this, the gradual improvement.1). " $ ("#id"), gets the ID of the specified element, the ID is globally unique, so it has only one member.2). " $ (". Class") ", gets th
(
$. LoadImage (src ),
$. AfterDOMReady (after)
). Then (function (){
Element. attr ("src", src );
}, Function (){
Element. attr ("src", "error.png ");
}). Done (function (){
Element. fadeIn ();
});
}
});
If we want to delay loading the image itself, the code will be different:
Copy codeThe Code is as follows:
$ ("Img"). each (function (){
Var element = $ (this ),
Src = element. attr ("data-src "),
After = element. attr ("data-after ");
If (src
. preventDefault (); // block open
$ (This). addClass ('evil '); // Add harmful class
}
});
There are two ways to automatically trigger an event. One is to directly use event functions, and the other is to use. trigger () or. triggerHandler ().
$ ('A'). click ();
$ ('A'). trigger ('click ');
9. Special Effects
JQuery allows objects to present certain special effects.
$('H1 '). show (); // displays an h1 title
Common special effects are as f
This article mainly introduces the definition of AMD asynchronous modules and the methods for using jQuery and jQuery plug-ins in Require. js. For more information, see
AMD Module
The overall goal of AMD (Asynchronous Module Definition) format is to provide an available modular JavaScript solution for developers.
The AMD module format itself is a proposal about how to define a module. In this definition, b
This article mainly introduces the definition of AMD asynchronous modules and the methods for using jQuery and jQuery plug-ins in Require. js. For more information, see
AMD Module
The overall goal of AMD (Asynchronous Module Definition) format is to provide an available modular JavaScript solution for developers.
The AMD module format itself is a proposal about how to define a module. In this definition, b
The versions downloaded from the Internet are more or less prone to bugs, especially the flash on IE6 and IE7 after loading. after a long time of searching on the internet, no related solutions have been found. If there is no solution, we have to take advantage of our DIY spirit, solve it by our own ideas, analyze the BUG, handle the logic, and solve Jquery by combining the methods I used to bring up window special effects some time ago. lazyLoad. for
The versions downloaded from the Internet are more or less prone to bugs, especially the flash on IE6 and IE7 after loading. after a long time of searching on the internet, no related solutions have been found. If there is no solution, we have to take advantage of our DIY spirit, solve it by our own ideas, analyze the BUG, handle the logic, and solve Jquery by combining the methods I used to bring up window special effects some time ago. lazyLoad. for
to pass the parameter.20-How to manipulate styles in jqueryAddClass () Append style, removeclass () Delete style, toggle () Toggle Style21-jquery How the event is handledLoad the document first, and when the page is loaded, the browser will add events to the DOM element via JavaScript.Animations in the 22-jqueryHide () and show () modify multiple style properties, such as height, width, and opacity. FadeIn
, click () is short for bind (). In jQuery 1.7, on () is the preferred method for appending event handlers. However, for consistency, you can simply use on (). // Bad condition first.click(function(condition condition parameter first.css ('border', '1px solid red'condition parameter first.css ('color', 'blue');}); condition ('border ', '1px solid red');}) // loads ('border', '1px solid red'{}{first.css ('color', 'blue');}) loads ('border ', '1px solid
provide more customization functions, and can customize the sequencer.
Code: (1) The sorted list is:
Copy Code code as follows:
(2) The jquery code is:
Copy Code code as follows:
var items = $ ('. To_order li '). get (); Get all pending Li
Items.Sort (function (a,b)//Call JavaScript built-in function sort, parameter is a closure function, that is, the sequencer
{
var Keya = $ (a). Val ();
var keyb = $ (b)
() function to switch the visible state of HTML elements.Hide the displayed elements.The speed parameter can be set to "slow", "fast", "normal", or milliseconds.
Jquery slide Function
-Slidedown, slideup, slidetoggle
Jquery has the following slide functions:
$ (Selector). slidedown (speed, callback)$ (Selector). slideup (speed, callback)$ (Selector). slidetoggle (speed, callback)
The peed parameter can be
"firstColumn", we need to use the selection operation for the table again, can't we call Methods consecutively? Fortunately, jQuery provides the end () function, which changes the list of matched elements to the previous state so that you can execute the method linked list:Copy the Code as follows:
$ ('# Mytable ')
. Find ('. firstColumn ')
. Css ('background', 'red ')
. End ()
. Find ('. lastColumn ')
. Css ('background', 'blue ');
It is also easy t
consecutively? Fortunately, jquery provides the end () function, which changes the list of matched elements to the previous state so that you can execute the method linked list:
$ ('# Mytable '). Find ('. firstcolumn '). CSS ('background', 'red '). End (). Find ('. lastcolumn '). CSS ('background', 'blue ');
It is also easy to write a custom jquery function that can be called in a method chain. What yo
active
Next, set the css style for it.
Note:
1. banner is the image carousel range, which is set to 400 in width and 200 in height. this is also true for the ul peripheral of the image.
2. to display active items, set display: none for all li settings, and then add the on class settings display: inline.
3. when using the fadeIn () of jquery, it is changed to display: list-item. Therefore, overflow: hidd
This article mainly introduces how to use JavaScript to implement the function of displaying comments by ID in WordPress, that is, to display the subject content of the comments in the building-style comments. For more information, see: A left A message and B replied to A with @, so B's reply may be like this:
@How much money do you have?
That is to say, when you hover the mouse over @ A, the comment of A will be displayed in A floating area.
StepsHere we will take the iNove topic as an exampl
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.