background preloader

Programming

Facebook Twitter

Starter | Jumpstart Your jQuery Plugin Development. .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. If the property requires units other than px, convert the value to a string and add the appropriate units before calling the method. When using .css() as a setter, jQuery modifies the element's style property.

For example, $( "#mydiv" ).css( "color", "green" ) is equivalent to document.getElementById( "mydiv" ).style.color = "green". 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: 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. This object is similar to the one that can be sent to the .css() method, except that the range of properties is more restrictive. 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).

Property values are treated as a number of pixels unless otherwise specified. 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. Duration. jQuery. 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…