• 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

Add a Class to an Element

Add a Class to an Element

To add a class to an element, you use the classList property of the element.

CSS

Get all of an element’s parent elements up the DOM tree

Get all of an element’s parent elements up the DOM tree

Let’s look at how to get all parent elements of a specific element.

CSS

Get the Children of an Element

Get the Children of an Element

To get the children of an element, you use the childNodes property of the element.

CSS

Get the Parent of an Element

Get the Parent of an Element

This snippet gets the parent of an element by using the parentNode property of the element.

CSS

Selecting Elements By Class Name

Selecting Elements By Class Name

To select elements by a given class name, you use the getElementsByClassName() method

CSS

Selecting an Element By Id

Selecting an Element By Id

Select an element that matches the id using the getElementById() method.

CSS

Text Sections

Text Sections

This script allows a user to read a volume of text, without having to scroll the page and without having to load different pages. This makes for easier maintenance as only one page needs to be updated, yet the content is visible to search engines. Very useful for large amounts of text.

CSS

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3

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