• 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

Generate a random hexadecimal color code

Generate a random hexadecimal color code

Use Math.random() to generate a random 24-bit (6 * 4bits) hexadecimal number.

Generators

Generate a random number in a given range with JavaScript

Generate a random number in a given range

The following snippet returns a random number between min (inclusive) and max (exclusive).

Math Related

Add items to an array in JavaScript

Add items to an array

Add items to an array. Pass the new items in as arguments.

Miscellaneous

Smooth Scroll to the Top of the Page With JavaScript

Smooth Scroll to the Top of the Page With JavaScript

Get distance from top using Document.documentElement or Document.body and Element.scrollTop.

Navigation

Get the largest number from a set of numbers

Get the largest number from a set of numbers

Math.max() returns the largest number from a set of numbers. Pass each number in as an argument.

Math Related

Remove HTML/XML tags from a string

Remove HTML/XML tags from a string

Use a regular expression to remove HTML/XML tags from a string.

Miscellaneous

Return the largest integer less than or equal to a number

Return the largest integer less than or equal to a number

Returns the largest integer (whole number) less than or equal to a number.

Math Related

Detect the preferred language of the current user

Detect the preferred language of the current user

Use Navigator.language or the first value of Navigator.languages if available, otherwise return defaultLang.

User Details

Get the absolute value of a number with JavaScript

Get the absolute value of a number

Get the absolute (positive) value of a number.

Math Related

Return the scroll position of the current page

Return the scroll position of the current page

Use Window.pageXOffset and Window.pageYOffset if they are defined, otherwise Element.scrollLeft and Element.scrollTop.

Navigation

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Interim pages omitted …
  • Go to page 26
  • 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