• 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

Scroll to an element smoothly (smooth scroll)

Scroll to an element smoothly (smooth scroll)

We can scroll to given element smoothly (smooth scroll) by passing behavior: ‘smooth’.

Navigation

Convert a string to a number

Convert a string to a number

Sometimes it returns integer. Other times it returns a float. And if you pass in a string with random text in it, you’ll get NaN, an acronym for Not a Number.

Miscellaneous

Check if array has duplicates

Check if array has duplicates

Checks if there are duplicate values in a flat array. Use Set to get the unique values in the array.

Miscellaneous

Make a resizable element

Make a resizable element

First, we need to prepare some elements that indicate the element is resizable. They are placed absolutely at the four sides of the original element.

Miscellaneous

Convert a string into an integer (a whole number)

Convert a string into an integer (a whole number)

Convert a string into an integer (a whole number).

Math Related

Remove a class from HTML element

Remove class from HTML element

Use Element.classList and DOMTokenList.remove() to remove the specified class from the element.

CSS

Make a draggable element

Make a draggable element

In order to make an element draggable, we need to handle three events.

Miscellaneous

Template Literals

Template Literals

Template literals provide a simpler way to create strings that span multiple lines or contain data.

Miscellaneous

Looping over an object’s keys and values

Looping over an object’s keys and values

In this example you have access to each pair using the key and value variables during the loop.

Miscellaneous

Take a number and return it in the specified currency formatting

Take a number and returns it in the specified currency formatting

Use Intl.NumberFormat to enable country / currency sensitive formatting.

Math Related

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