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

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Forum
  • 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

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

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

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

Miscellaneous

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

Check if a date is between two other dates

Use the greater than (>) and less than (<) operators to check if date is between dateStart and dateEnd.

Time & Date

Get the Children of an Element

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

CSS

Scroll to an element smoothly

This snippet produces a smooth scrolling implementation which also allows us to customize the animation effect and duration.

Navigation

Scroll to top of the page

Utilizing this snippet, you can add a button at the bottom of page that allows user to scroll to the top quickly.

Navigation

Check if the browser tab of the page is focused

Use the Document.hidden property, introduced by the Page Visibility API to check if the browser tab of the page is visible or hidden.

Page Details

Get Siblings of an Element

This snippet gets the next sibling and previous sibling of an element, using the element.nextSibling and element. previousSibling properties.

Miscellaneous

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 9
  • Go to Next Page »

Primary Sidebar

Copyright © 2021 JavaScriptSource.com

  • About
  • Privacy Policy
  • Submit
  • FAQ
  • Jobs For Developers
  • Contact Us