• 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

Check if a date is between two other dates

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

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

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

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

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

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

Generating random numbers with JavaScript

Generating random numbers with JavaScript

In this snippet, look at how to get a random integer between two numbers.

Math Related

Get size of the selected file

Get size of the selected file

This snippet can be used to validate a file’s size and display it, for instance when a file is being submitted for upload.

Miscellaneous

Check if the given number is even

Check if the given number is even

Check whether a number is odd or even using the modulo (%) operator. Return true if the number is even, false if the number is odd.

Math Related

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

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