Latest web development tutorials

jQuery jQuery.cssHooks method

jQuery HTML / CSS Methods jQuery HTML / CSS Methods

Examples

Define a new css hook

$ (Function ($) { // First check jquery version supports cssHooks if (! $. CssHooks) { // If it does not remind output error throw (new Error ( "This feature requires jQuery 1.4.3 version is greater than or equal to"));} // Encapsulated in Dom document loaded event, the written cssHooks again this time, avoid the cssHooks be rewritten elsewhere $ (Function () {$. CssHooks. Height = { get: function ( elem, computed, extra ) { // Handle to get the CSS property }, Set: function ( elem, value ) { // Handle Set CSS properties alert ( 'execution processing');} }; $ ( 'Body') css ( 'height', '100%');.});}) (JQuery)

try it"

Definition and Usage

$ .cssHooks Is provided a method defined functions to get and set specific CSS value.


Note: 1. It aims to standardize CSS property name or create a custom attribute.
2. For example, some versions of Webkit-based browser needs -webkit-border-radius property to set the border-radius element, and early versions of Firefox -moz-border-radius property. A CSS hook can standardize these properties have the prefix, so .css () accepts a single, standard name attribute (border-radius, or DOM attribute syntax, borderRadius).


grammar

$.cssHooks


Examples

More examples

Var test browser vendor prefixes
In making vendor-specific CSS properties standardization, we should first determine whether the browser supports the standard attributes or variant with a browser vendor prefixes.

Define a complete css hook
Define a complete css hook.


jQuery HTML / CSS Methods jQuery HTML / CSS Methods