• 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
Home / Archives for Miscellaneous

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

Wrap an element around a given element

Wrap an element around a given element

Wrap the wrapper element around the ele element.

Miscellaneous

Remove duplicate items from an array

Remove duplicate items from an array

To remove any duplicates, we can pass our array into the new Set() constructor, then convert the returned collection back into an array.

Miscellaneous

Check if all the elements in values are included in arr

Check if all the elements in values are included in arr

Use Array.prototype.every() and Array.prototype.includes() to check if all elements of values are included in arr.

Miscellaneous

Detect Caps Lock Is On

Detect Caps Lock Is On

To check if the caps lock is on, you use the getModifierState() method of the KeyboardEvent object.

Miscellaneous

Check if at least one element of values is included in arr

Check if at least one element of values is included in arr

Use Array.prototype.some() and Array.prototype.includes() to check if at least one element of values is included in arr.

Miscellaneous

Press shift and enter for a new line

Press shift and enter for a new line

In some cases such as an inline editable element, or a messaging application, you would like to submit the data when user presses Enter. The only way to generate a new line is to press Shift and Enter.

Miscellaneous

Insert an HTML string after the end of the specified element

Insert an HTML string after the end of the specified element

Use Element.insertAdjacentHTML() with a position of ‘afterend’ to parse htmlString and insert it after the end of el.

Miscellaneous

Insert an HTML string before the start of the specified element

Insert an HTML string before the start of the specified element

Use Element.insertAdjacentHTML() with a position of ‘beforebegin’ to parse htmlString and insert it before the start of el.

Miscellaneous

Clone an element

Clone an element

Using the cloneNode(true) method will deep copy a given element.

Miscellaneous

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