Easy Tutorial
❮ Jquery Install Misc Type ❯

jQuery jQuery.cssHooks Method

jQuery HTML/CSS Methods

Example

Define a new CSS hook

$(function ($) { 
    // First, check if the jQuery version supports cssHooks 
    if (!$.cssHooks){
        // If not supported, output an error message
        throw(new Error("This feature requires jQuery version 1.4.3 or higher"));
    }

    // Wrap in the DOM document ready event to ensure cssHooks are written at the right time, preventing them from being overwritten elsewhere
    $(function(){
        $.cssHooks.height = {
            get: function( elem, computed, extra ) {
                // Handle getting the CSS property
            },set: function( elem, value ) {
                // Handle setting the CSS property
                alert('Executing handler');
            }
        };
        $('body').css('height','100%');
    });
})(jQuery)

Definition and Usage

$.cssHooks provides a method to define functions for getting and setting specific CSS values.

Note: 1. Its purpose is to standardize CSS property names or create custom properties.


Syntax


More Examples

Test browser vendor prefix variants

Define a complete CSS hook


jQuery HTML/CSS Methods

❮ Jquery Install Misc Type ❯