• 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

Toggle a class for an HTML element

Toggle a class for an HTML element

toggleClass toggles a class for an HTML element.

CSS

Drag and drop element in a list

Drag and drop element in a list

Create a sortable list whose items can be dragged and dropped inside it.

Miscellaneous

Convert a string into an array

Convert a string into an array

Convert a string into an array by splitting it after a specific character (or characters).

Miscellaneous

Check if the given string contains any whitespace characters

Check if the given string contains any whitespace characters

Use RegExp.prototype.test() with an appropriate regular expression to check if the given string contains any whitespace characters.

Miscellaneous

Create an image comparison slider

Create an image comparison slider

Create a slider for comparing two images visually. The slider has three elements.

Image Effects

Replace a portion of a string with something else

Replace a portion of a string with something else

The replace() method accepts two arguments: the string to find, and the string to replace it with.

Miscellaneous

The Exponent Operator

The Exponent Operator

Do you useMath.pow() to raise a number to a power? Did you know you can use the exponent operator ** as well?

Math Related

Detect whether the page is being viewed on a mobile device or a desktop

Detect whether the page is being viewed on a mobile device or a desktop

Use a regular expression to test the navigator.userAgent property to figure out if the device is a mobile device or a desktop.

User Details

Create a range slider

Create a range slider

This post introduces two popular ways to create a range slider.

Forms

Transform all text in a string to lowercase

Transform all text in a string to lowercase

Use String.toLowerCase() to transform all text in a string to lowercase.

Miscellaneous

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 13
  • Go to page 14
  • Go to page 15
  • Go to page 16
  • Go to page 17
  • 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