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

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

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 18
  • Go to page 19
  • Go to page 20
  • Go to page 21
  • Go to page 22
  • Interim pages omitted …
  • Go to page 28
  • Go to Next Page »

Primary Sidebar

FREE UPDATES!

Get the latest updates in your inbox for FREE!

Popular Posts

Story Generator

IP Grabber

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2022 JavaScriptSource.com

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