JQuery provides the following ways to achieve the fade effect shown:
FadeIn ()
Fadeout ()
Fadetoggle ()
Fadeto ()
FadeIn () method
FadeIn () implements the fade effect with the following basic syntax:
$ (selector). FadeIn (Speed,callback);
Optional parameter speed gi
Anyone who has used AJAX technology knows the famous JQuery. Although I have watched AJAX videos before, I was still vague about WEB applications at that time, but I don't know how HTML, JSP, and Servlet work, I don't even know what JQuery is packaging. Today's learning combined with yesterday's JavaScriptDOM content makes me very clear about this. JQuery princip
JQuery plug-in development and jQuery. extend function details are different from jQuery. fn and jQuery. prototype. jquery. fn. extendI. jQuery plug-in development is divided into two types:1. class level:You can understand the cl
This refers to the native JS Dom object. CSS (""): Write only one value is value, write two values is assignmentWindow.onload = = = $ (document). Ready ();$ (""): Gets the element tag name,. Class name, #idJQuery features
Chained programming
Jq.shou (in). HTML (content)
Equivalent
Jq.shou (3000)
jq.gtml (content)
Implicit iteration
Implicit practical for loop, iterationHow to use
The chain operation of jQuery implementation method is very easy. This is used below.
The Code is as follows:
// Bad$Second.html (value );$ Second. on ('click', function (){Alert ('Hello everbody ');});$ Second. fadeIn ('slow ');$ Second. animate ({height: '120px '}, 500 );
The Code is as follows:
// Suggestions$Second.html (value );$ Second. on ('click', function (){Alert ('Hello everbody ');}).
It is not uncommon to discuss jQuery and javascript performance. However, I plan to summarize some speed tips and some of my own suggestions in this article to improve your jQuery and javascript code. Good code will increase the speed. Quick rendering and response means a better user experience. First, remember that jQuery is javascript in your mind. This means w
, jQuery's default animation queue ). It allows you to pause between two animation actions, instead of involving callback functions and setTimeout .. The first parameter of delay () is the number of milliseconds you need to set:
Js Code
JQuery ('# foo ')
. SlideDown () // Slide down
. Delay (200) // Do nothing for 200 MS
. FadeIn (); // Fade in
JQuery ('# foo '
('border', '1px solid red ');})
Simplified javascriptIn general, it is best to merge functions as much as possible.
// Bad$ First. click (function (){Define first.css ('border', '1px solid red ');Define first.css ('color', 'blue ');});// Suggestions$ First. on ('click', function (){$First.css ({'Border': '1px solid red ','Color': 'blue'});});
The Code is as follows:
// Bad$ First. click (function (){Define first.css ('border', '1px solid red ');Define first.css ('color', 'blue ');});// Sugges
This article describes examples of jquery's Common special effects. For more information, see section 1. Use jQuery fadeIn () to fade in hidden elements.
Syntax:
The Code is as follows:
$ (Selector). fadeIn (speed, callback );
Instance:
The Code is as follows:
$ ("Button"). click (function (){$ ("# P1"). fadeIn ();
external margins, and transparency of the element are gradually changed from hidden to completely visible.
Callback (optional) indicates the function to be executed after the show function is executed.
2. Hide control elements
In jQuery, the show method corresponds to the hide method.
The Hide method is used for hiding (you can control the hiding speed of elements)
Syntax:
$ (Selector). hide ([speed], [callback]);
Its parameters are the same as thos
Improvement of front-end programming (2) ---- jquery implementation of common website special effects ---- jquery
The best programming language is logic. jquery can be used to implement various interactive effects on the front end. Special effects can be varied, while the internal logic remains unchanged. This article describes the logic behind jquery's Implement
;// Suggestions nbsp; $first. On (' click ', Function () {nbsp; nbsp; $first. css ({nbsp; nbsp; nbsp; ' border ': ' 1px solid red ', nbsp; nbsp; nbsp; nbsp; ' color ': ' Blue ' nbsp; nbsp;} '; }); nbsp; 7. Chained operation of the jquery implementation method is very easy. Let's take advantage of that. The code is as follows://Bad nbsp; $second. html (value); $second. On (' click ', Function () {nbsp; nbsp; alert (' Hello Everybody ');}); $second.
Today's study combined with yesterday's javascriptdom content, let me be very clear about this. The jquery principle: "Write less, do more.", this sentence has fully explained its ability to simplify the use of JAVASCRIPTDOM programming!
Each teacher has his or her own way of teaching, which may vary slightly according to the teaching method of the professor's content. Old Tong is a very experienced software teacher, before he in Dalian software compa
, the Class selector is the slowest selector; in IE, It loops through the entire DOM. Avoid using it if possible. Do not add Tags before the ID. For example, it loops through all the
var content = $('div#content');
In the same way, transmitting data from multiple IDS is redundant.
var traffic_light = $('#content #traffic_light');
3. cache jQuery objects
Develop the habit of saving jQuery objects to a varia
of an event (for example, clicking a link will automatically open a new page) event. stopPropagation () Stop the event and bubble up the Layer Element
In the event processing function, you can use the this keyword to return the DOM elements targeted by the event.
$ ('A '). click (function () {if ($ (this ). attr ('href '). match ('evil ') {// if it is identified as harmful link e. preventDefault (); // block opening $ (this ). addClass ('evil '); // Add harmful class }});
There are two ways to
(function(){ $("button"). Click (function(){ $("P"). Toggle (); });});/*$ (selector). Toggle (speed,callback); The optional speed parameter specifies the rate of concealment/display, which can take the following values: "Slow", "fast", or milliseconds. The optional callback parameter is the function name that is executed after the toggle () method completes. */$ (document). Ready (function(){ $("button"). Click (function(){ $("P"). Toggle (1000); });});//---of
solid red ',
' Color ': ' Blue '
});
});
7. Chain Type operation
The chain operation of the JQuery implementation method is very easy. Let's take advantage of that.
Copy Code code as follows:
Bad
$second. HTML (value);
$second. On (' click ', function () {
Alert (' Hello everybody ');
});
$second. FadeIn (' slow ');
$second. Animate ({height: ' 120px '},500);
summary, see http://docs.jquery.com/Effects/animate
The following is an example. the id is "note" div. calling animate () triggers the click () event of the jQuery library by clicking.
$ Params = array ('Height' => 80,'Width' => '123 ','Marginleft' = gt; 125);$ This-> jquery-> click ('# trigger', $ this-> jquery-> animate (' # note', $ params, normal ));
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.