• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Forum
  • 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

Return the current URL

Return the current URL

Use Window.location.href to get the URL of the current page.

Page Details

JavaScript Arrays Explained

JavaScript Arrays Explained

Arrays are container-like values that can hold other values. The values inside an array are called elements.

Basics

Get the direction of the text selection

Get the direction of the text selection

This function returns forward if user selected text from the left to right. It returns backward in the other case.

Text Effects

Get and set inline styles for an element

Get and set inline styles for an element

Get a style, and then if this style is not set as an inline style directly on the element, it returns an empty string.

CSS

One-Liner If-Else Statements

One-Liner If-Else Statements

Instead of writing an if-else on multiple lines, you can use the ternary operator to write the whole statement with one line of code.

Basics

Get the currently selected text with JavaScript

Get the currently selected text

Use Window.getSelection() and Selection.toString() to get the currently selected text.

Text Effects

Javascript Conditionals Explained

Javascript Conditionals Explained

Conditional statements control behavior in JavaScript and determine whether or not pieces of code can run.

Basics

Get the default value of a CSS property with JavaScript

Get the default value of a CSS property

The following function returns the default value of CSS property for given tagName.

CSS

How to loop through arrays and array-like objects in JavaScript

Loop through arrays and array-like objects

Here is how to loop through arrays and array-like objects using JavaScript.

Miscellaneous

How to Get the Query String in JavaScript

How to Get the Query String in JavaScript

When you’re working with JavaScript, sometimes you need to access query string parameters in your script.

Miscellaneous

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 17
  • 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 © 2021 JavaScriptSource.com

  • About
  • Privacy Policy
  • Submit
  • FAQ
  • Jobs For Developers
  • Contact Us