• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Archives for CSS

CSS

Check if HTML element has class

Check if HTML element has class

Use Element.classList and DOMTokenList.contains() to check if the element has the specified class. Source https://www.30secondsofcode.org/js/s/has-class

CSS

Retrieve the value of a CSS rule for the specified element

Retrieve the value of a CSS rule for the specified element

Use Window.getComputedStyle() to get the value of the CSS rule for the specified element.

CSS

Remove a class from HTML element

Remove class from HTML element

Use Element.classList and DOMTokenList.remove() to remove the specified class from the element.

CSS

Toggle a class for an HTML element

Toggle a class for an HTML element

toggleClass toggles a class for an HTML element.

CSS

Create a custom scrollbar

Create a custom scrollbar

You can customize the look and feel of the browser’s scrollbar by changing some CSS properties.

CSS

Resize the width of a text box to fit its content automatically

Resize the width of a text box to fit its content automatically

To adjust its width based on its content dynamically, we create a fake element whose content is the same as the input value.

CSS

Check if an element has an attribute

Check if an element has an attribute

Check for the existence of an attribute (including data attributes) on an element. This method can also be used to manipulate other types of attributes—things like id, tabindex, name, and so on.

CSS

Get the computed style of an element

Get the computed style of an element

Get the actual computed style of an element. This factors in browser default stylesheets as well as external styles you’ve specified.

CSS

Get and set inline styles for an element

Get and set inline styles for an element

Get a style, and then if this style is not set as an inline style directly on the element, it returns an empty string.

CSS

Get the default value of a CSS property with JavaScript

Get the default value of a CSS property

The following function returns the default value of CSS property for given tagName.

CSS

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to Next Page »

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers