.css Description: Set one or more CSS properties for the set of matched elements. As with the .prop() method, the .css() method makes setting properties of elements quick and easy. This method can take either a property name and value as separate parameters, or a single object of key-value pairs. When a number is passed as the value, jQuery will convert it to a string and add px to the end of that string. When using .css() as a setter, jQuery modifies the element's style property. As of jQuery 1.8, the .css() setter will automatically take care of prefixing the property name. As of jQuery 1.6, .css() accepts relative values similar to .animate(). As of jQuery 1.4, .css() allows us to pass a function as the property value: This example sets the widths of the matched elements to incrementally larger values. Note: If nothing is returned in the setter function (ie. function( index, style ){} ), or if undefined is returned, the current value is not changed. Demo:
.animate Description: Perform a custom animation of a set of CSS properties. The .animate() method allows us to create animation effects on any numeric CSS property. The only required parameter is a plain object of CSS properties. Animation Properties and Values All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality (For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color plugin is used). In addition to style properties, some non-style properties such as scrollTop and scrollLeft, as well as custom properties, can be animated. Shorthand CSS properties (e.g. font, background, border) are not fully supported. In addition to numeric values, each property can take the strings 'show', 'hide', and 'toggle'. Animated properties can also be relative. Duration Callback Functions Basic Usage Step Function Easing Per-property Easing Demo:
Things you may not know about jQuery I was going to do a bit of a series, releasing a jQuery tip every day or week or something, but I think I’m a little too lazy to commit to something like that. So I’ve compiled them all into one post! I’ll probably add to the list at later dates so make sure to bookmark it! Do you have a tip nobody knows about? – Add it in the comments…