• 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 the given value is a number

Check if the given value is a number

Use parseFloat() to try to convert n to a number. Use !Number.isNaN() to check if num is a number.

Math Related

Trigger an event

Trigger an event

There are some special events that are avaialble as the method’s element.

Forms

Get all direct descendant elements that match a test

Get all direct descendant elements that match a test

To do this, we need to combine Node.children with a few other techniques.

Miscellaneous

Check if all elements in an array are equal

Check if all elements in an array are equal

Use Array.prototype.every() to check if all the elements of the array are the same as the first one.

Miscellaneous

Detect If an Element has focus

Detect If an Element has focus

To detect if an element has the focus, you use the read-only property activeElement of the document object.

Miscellaneous

Upload files with ajax

Upload files with ajax

This function sends selected files from a fileEle element to a back-end.

Ajax

Sanitize an HTML string to reduce the risk of XSS attacks

Sanitize an HTML string to reduce the risk of XSS attacks

Sanitizing is the process of removing any attributes, properties, and values that are not included in an allowlist or that are explicitly forbidden on a disallow list.

Miscellaneous

Open or close an element in fullscreen mode

Open or close an element in fullscreen mode

Use Document.querySelector() and Element.requestFullscreen() to open the given element in fullscreen.

Miscellaneous

Check If the Document is Ready

Check If the Document is Ready

To check if the document is ready and execute some code, you bind an event listener to the DOMContentLoaded event of the document object.

Page Details

Wrap an element around a given element

Wrap an element around a given element

Wrap the wrapper element around the ele element.

Miscellaneous

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 21
  • Go to page 22
  • Go to page 23
  • Go to page 24
  • Go to page 25
  • 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