• 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

Get Width and Height of an Element

Get Width and Height of an Element

To get the width and height of an element, you use the offsetWidth and offsetHeight properties of the element.

Page Details

Detect the dark mode

Detect the dark mode

Modern operating systems allow users to choose the appearance they would like to see in all applications. The option can be detected by looking at the prefers-color-scheme media query.

User Details

Check if a date is after another date

Check if a date is after another date

Use the greater than operator (>) to check if the first date comes after the second one.

Time & Date

Get all siblings of an element

Get all siblings of an element

A simplified approach using some ES6 methods.

Miscellaneous

Get the text content of an element

Get the text content of an element

Returns the raw text content of the ele element and its children.

Text Effects

Get the Width and Height of the Window

Get the Width and Height of the Window

How to get the width and height of the window in px.

Page Details

Check if a date is before another date

Check if a date is before another date

Use the less than operator (<) to check if the first date comes before the second one.

Time & Date

Check if two arrays or objects are equal

Check if two arrays or objects are equal

A robust way to compare two arrays (or objects) and check if they’re equal to each other.

Miscellaneous

Prevent the default action of an event

Prevent the default action of an event

Use the preventDefault() method. This method works with inline attribute.

Miscellaneous

Get and Set Scroll Position of an Element

Get and Set Scroll Position of an Element

To set or get the scroll position of an element, you use the properties scrollTop and scrollLeft of the element.

Page Details

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 25
  • Go to page 26
  • Go to page 27
  • Go to page 28
  • Go to page 29
  • Interim pages omitted …
  • Go to page 36
  • 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