From f8384a3a2a4f71d2eb2244361eb89efb04b92020 Mon Sep 17 00:00:00 2001 From: Sven Minio Date: Sun, 17 May 2026 19:27:45 +0200 Subject: [PATCH] Add CSS Classes & Styles --- CSS-Classes-%26-Styles.md | 128 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 CSS-Classes-%26-Styles.md diff --git a/CSS-Classes-%26-Styles.md b/CSS-Classes-%26-Styles.md new file mode 100644 index 0000000..ecf1213 --- /dev/null +++ b/CSS-Classes-%26-Styles.md @@ -0,0 +1,128 @@ +* [`css`](#usage-css) +* [`addClass`](#usage-addClass) | [`removeClass`](#usage-removeClass) | [`toggleClass`](#usage-toggleClass) | [`hasClass`](#usage-hasClass) + +--- + +## .css + +**Description** +Get the value of a computed style property for the first element in the set of matched elements or set one or more CSS properties for every matched element. + +**Parameters** + +* `property` (String|Object): A CSS property name or an object of property-value pairs. +* `value` (String|Number, optional): A value to set for the property. + +**Returns** + +* (String): The value of the property (if getter). +* (jBase): Current instance (if setter). + +**Example** + +```javascript +// Get value +const color = $('.box').css('color'); + +// Set single value +$('.box').css('width', '500px'); + +// Set multiple values +$('.box').css({ + 'background-color': 'blue', + 'font-size': '14px' +}); + +``` + +--- + +## .addClass + +**Description** +Adds the specified class(es) to each element in the set of matched elements. + +**Parameters** + +* `className` (String): One or more class names to be added to the class attribute of each matched element. + +**Returns** + +* (jBase): Current instance. + +**Example** + +```javascript +$('p').addClass('lead text-muted'); + +``` + +--- + +## .removeClass + +**Description** +Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + +**Parameters** + +* `className` (String): One or more class names to be removed. + +**Returns** + +* (jBase): Current instance. + +**Example** + +```javascript +$('.active').removeClass('active'); + +``` + +--- + +## .toggleClass + +**Description** +Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument. + +**Parameters** + +* `className` (String): One or more class names to be toggled. + +**Returns** + +* (jBase): Current instance. + +**Example** + +```javascript +$('.btn').click(function() { + $(this).toggleClass('btn-active'); +}); + +``` + +--- + +## .hasClass + +**Description** +Determine whether any of the matched elements are assigned the given class. + +**Parameters** + +* `className` (String): The class name to search for. + +**Returns** + +* (Boolean): True if the class is present, false otherwise. + +**Example** + +```javascript +if ($('#menu').hasClass('open')) { + $('#menu').slideUp(); +} + +``` \ No newline at end of file