• 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

Drag to scroll

drag to scroll

This post shows you a simple way to allow users to scroll by dragging the element with vanilla JavaScript.

Navigation

Determine if a string contains a substring

Determine if a string contains a substring

String.indexOf() returns the index of where the substring starts in the string, or -1 if the substring isn’t found.

Miscellaneous

Finding a specific object in an array of objects

Finding a specific object in an array of objects

Iterating through an array of objects to find a specific one.

Miscellaneous

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

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 5
  • Go to page 6
  • Go to page 7
  • Go to page 8
  • Go to page 9
  • 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