diff --git a/entries/css.xml b/entries/css.xml index 85a304e8..9d7aa922 100644 --- a/entries/css.xml +++ b/entries/css.xml @@ -152,9 +152,9 @@ $( "div" ).on( "click", function() {
top, right, bottom, leftwidth, height, min-width, min-height, max-width, max-heightpadding-related: padding, padding-top, padding-right, padding-bottom, padding-leftmargin-related: margin, margin-top, margin-right, margin-bottom, margin-leftborder-related: border, border-width, border-top, border-top-width, border-right, border-right-width, border-bottom, border-bottom-width, border-left, border-left-widthpadding, padding-top, padding-right, padding-bottom, padding-leftmargin, margin-top, margin-right, margin-bottom, margin-leftborder, border-width, border-top, border-top-width, border-right, border-right-width, border-bottom, border-bottom-width, border-left, border-left-widthWhen 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". Setting the value of a style property to an empty string — e.g. $( "#mydiv" ).css( "color", "" ) — removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery's .css() method, or through direct DOM manipulation of the style property. As a consequence, the element's style for that property will be restored to whatever value was applied. So, this method can be used to cancel any style modification you have previously performed. It does not, however, remove a style that has been applied with a CSS rule in a stylesheet or <style> element. Warning: one notable exception is that, for IE 8 and below, removing a shorthand property such as border or background will remove that style entirely from the element, regardless of what is set in a stylesheet or <style> element.
Note: .css() doesn't support !important declarations. So, the statement $( "p" ).css( "color", "red !important" ) does not turn the color of all paragraphs in the page to red as of jQuery 3.6.0. Do not depend on that not working, though, as a future version of jQuery may add support for such declarations. It's strongly advised to use classes instead; otherwise use a jQuery plugin.