.css()
• .css('property','value')
• .css({property1: 'value1', 'property-2': 'value2'})
引用
Numeric values do not take quotation marks while string values do.
But, when using the map notation, quotation marks are not required for
property names if they are written in camel-cased DOM notation.
.hide() .show() .animate
Basic .hide() and .show(), without any parameters, can be thought of as smart shorthand methods for .css('display','string'), where string is the
appropriate display value. The effect, as might be expected, is that the matched set of elements will be immediately hidden or shown, with no animation. The .hide() method sets the inline style attribute of the matched set of elements to display:none. The smart part here is that it remembers the value of the display property—typically block or inline—before it was changed to none. Conversely, the .show() method restores the matched set of elements to whatever visible display property they had before display:none was applied.
antimate()
However, jQuery also provides a powerful animate() method that allows us to create our own custom animations with multiple effects. The animate method takes four arguments:
1. A map of style properties and values—similar to the .css() map discussed
earlier in this chapter
2. An optional speed—which can be one of the preset strings or a number
of milliseconds
3. An optional easing type—an advanced option discussed in Chapter 10
4. An optional callback function—which will be discussed later in this chapter
All together, the three arguments would look like this:
.animate({param1: 'value1', param2: 'value2'}, speed, function() {
alert('The animation is finished.');
});
Remember that .show('slow') simultaneously modifies the width, height, andopacity. In fact, this method is really just a shortcut for the .animate() method, with a specific set of built-in style properties.
.show('slow');
. animate({height: 'show', width: 'show',
opacity: 'show'}, 'slow');
分享到:
相关推荐
英文版的 Chapter 1: Putting jQuery in Context 1 ...Chapter 34: Using the jQuery Utility Methods929 Chapter 35: The jQuery UI Effects & CSS Framework 945 Chapter 36: Using Deferred Objects 963
Developers can add new methods to the JQuery prototype, creating custom functionalities that can be reused throughout their applications. - **Example:** `$.fn.myPlugin = function(options) { /* Your ...
- **Extending jQuery**: Developers can extend the functionality of jQuery by adding custom methods to the jQuery prototype. - **Using jQuery with Other Libraries**: jQuery integrates seamlessly with ...
Chapter 4: User Registration and Management 47 Session authentication 47 Creating the login page 48 Enabling logout functionality 53 Improving template structure 54 User registration 59 Django ...
The standalone chapter structure leaves you free to explore ASP.NET MVC to immediately solve your pain points Book Description ASP.NET Core MVC helps you build robust web applications using the Model-...
Chapter 4: Let’s Get Started With Laravel . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Set Up The Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 ...