Feature detection.
Description
The jQuery.support
jQuery global object property, contains a collection of properties representing the presence of different browser features or bugs.
Shorthand version $.support
- Primarily intended for jQuery's internal use.
This method was deprecated in jQuery 1.9.
Syntax
Signature |
Description |
jQuery.support | Collection of properties representing the presence of different browser features or bugs.
- appendChecked - set to
true if a disconnected checkbox will retain its checked.
- ajax - set to
true if current browser is able to create a XMLHttpRequest object.
- boxModel - set to
true if the page is rendering according to the W3C CSS Box Model.
- changeBubbles - set to
true if the change event bubbles up the DOM tree, as required by the W3C DOM event model. (It is currently false in IE8 and below, and jQuery simulates bubbling).
- checkClone - set to
true if a browser correctly clones the checked state of radio buttons and checkboxes in document fragments.
- checkOn - set to
true if if the value of a checkbox defaults to 'on' when no value is specified.
- cors - set to
true if a browser can create an XMLHttpRequest object and if that XMLHttpRequest object has a withCredentials property. To
enable cross-domain requests in environments that do not support cors yet but do allow cross-domain XHR requests set $.support.cors = true; .
- cssFloat - set to
true if the name of the property containing the CSS float value is .cssFloat , as defined in the CSS Spec. (It is currently false in IE8 and below, as these versions use styleFloat instead).
- deleteExpando - set to
true if it's possible to delete an expando from an element. (It is currently false in IE8 and below).
- doesAddBorderForTableAndCells - set to
true if a border is added for tables and cells.
- doesNotAddBorder - set to
true if a border is not added.
- doesNotIncludeMarginInBodyOffset - set to
true if no margin is included in the body offset.
- enctype - set to
true if enctype support on a form.
- fixedPosition - set to
true if fixed positioning is supported.
- focusinBubbles - set to
true if the focusin event bubbles up the DOM tree. It is currently true in IE and false in all other browsers.
- getSetAttribute - set to
true if camelCase class testing passes. It is currently false in IE7 and below.
- hrefNormalized - set to
true if the .getAttribute() method retrieves the href attribute of elements unchanged, rather than normalizing it to a fully-qualified URL.
(It is currently false in IE7 and below, the URLs are normalized).
- html5Clone - set to
true if cloning an html5 element doesn't cause problems.
- htmlSerialize - set to
true if the browser is able to serialize/insert link elements using the .innerHTML property of elements. (It is currently set to
false in IE8 and below).
- inlineBlockNeedsLayout - set to
true if inline blocks need a layout. (It is currently true in IE7 and below).
- leadingWhitespace - set to
true if the browser inserts content with .innerHTML as provided—specifically, if leading whitespace characters are preserved. (It is currently false in IE8 and below).
- noCloneChecked - set to
true if cloned DOM elements copy over the state of the .checked expando. (It is currently set to false in all versions of IE).
- noCloneEvent - set to
true if cloned DOM elements are created without event handlers on the source element being cloned). (It is currently set to false in IE8 and below).
- opacity - set to
true if a browser can properly interpret the opacity style property. (It is currently false in IE8 and below, which use alpha filters instead).
- optDisabled - set to
true if option elements within disabled select elements are not automatically marked as disabled.
- optSelected - set to
true if an option element that is selected by default has a working selected property. (It is currently set to false in all versions of IE).
- radioValue - set to
true if a radio maintains its value after being appended to the DOM. (It is currently false in all versions of IE and Opera.
- reliableHiddenOffsets - set to
true if empty table cells still have offsetWidth/Height. (It is currently false in IE8 and below.
- reliableMarginRight - set to
true if right margins get computed correctly for divisions with setwidth and no right margin.
- shrinkWrapBlocks - set to
true if elements with layout shrink-wrap their children. (It is currently true in IE6).
- style - set to
true if inline styles for an element can be accessed through the DOM attribute called style , as required by the DOM Level 2 specification. If this
is the case, .getAttribute('style') can retrieve this value. (In IE8 and below .cssText is used for this purpose.
- submitBubbles - set to
true if the change event bubbles up the DOM tree, as required by the W3C DOM event model. (It is currently false in IE8 and below, and jQuery simulates bubbling).
- subtractsBorderForOverflowNotVisible - set to
true if border dimensions are subtracted from overflow that is not visible on the page.
- tbody - set to
true if an empty table element can exist without a tbody element. According to the HTML specification, this sub-element is optional,
so the property should be true in a fully-compliant browser. (It is currently false in IE7 and below which automatically inserts the tbody element if it is not present in a string
assigned to innerHTML ).
|
Parameters
None.
Return
An Object
object.
jQuery.support
Example
Utilities << Top
Collection of properties representing the presence of different browser features or bugs.
In the example below when we iterate through the jQuery.support
property copying each element to a new array. We then sort and print the settings (which may vary dependant upon the browser you are using).
$(function(){
$('#btn22').one('click', function(){
$('#div18').append('jQuery $.support properties for your browser: ' + '<br>');
var arr0 = [];
$.each($.support, function(index, value) {
arr0.push(index + ': ' + value);
});
arr0.sort();
$.each(arr0, function(index, value) {
$('#div18').append( index + ': ' + value + '<br>');
});
});
});
div18. Some initial text.
Related Tutorials
jQuery Intermediate Tutorials - Lesson 9 - jQuery General Utilities