How-to articles, tricks, and solutions about JAVASCRIPT

How to Get the Value of Selected Option in a Select Box

Read the tutorial and learn the methods of getting the value of the selected option in a select box using jQuery. Read about the text() and val() methods.

How to Get the Value of Text Input Field Using JavaScript

Read this tutorial and learn about several methods of getting the value of the input textbox value without wrapping the input element inside a form element.

How to Get URL Parameters

Read this JavaScript tutorial and learn how you can easily get the URL parameters with the help of the methods provided by the URLSearchParams interface.

How to Hide and Show a <div>

Read this tutorial and learn several CSS, JavaScript and jQuery methods of hiding and showing the <div> element. Also, you can find examples and try them.

How to HTML-encode a String

Read this JavaScript tutorial and learn about some useful and fast methods that help you to HTML-encode the string without causing the XSS vulnerability.

How to Include a JavaScript File in Another JavaScript File

Read the tutorial and find out different approaches to including a JavaScript file in another JavaScript file. Also, find a brief representation of methods.

How to Insert an Element After Another Element in JavaScript

Read this JavaScript tutorial and learn useful information about modern approaches of inserting an element after another element using two easy methods.

How to Insert an Item into an Array at a Specific Index

Read this JavaScript tutorial and learn the right method of inserting an item into an array at a specific index. Try examples and copy the code right away.

How to Know which Radio Button is Selected using jQuery

Read this JavaScript tutorial and learn the method of getting the value of the selected radio button with the help of jQuery. Copy the code right away.

How to List the Properties of a JavaScript Object

Read this tutorial and learn useful information about the two popular built-in methods that are used for listing the properties of the object in JavaScript.

How to Loop through an Array in JavaScript

The most common ways to loop through an array in JavaScript are the for, for/in and while loops. See how to use them. Examples.

How to Loop Through Array and Remove Items Without Breaking the For Loop

Read this JavaScript tutorial and learn some useful information about the method of looping through an Array and removing items without breaking for loop.

How to Loop Through or Enumerate a JavaScript Object

Read this tutorial and learn several useful methods of looping through or enumerate a JavaScript object. Try and copy the piece of the code right away.

How to Make a Div Stick to the Top of Screen when Scrolling with CSS and Javascript

This snippet will help you to make a <div> stick to the top of the screen when you scroll the page. Find out how to this using HTML, CSS, and Javascript.

How to Make HTTP GET Request in JavaScript

Read the tutorial and learn the how to make an HTTP GET request in JavaScript and make an asynchronous request and handle the response inside event handler.

How to Make JavaScript Execute After Page Load

Read this JavaScript tutorial and learn which are the two most used methods of making the script execute as soon as the webpage has completely loaded.

How to Manage a Redirect Request after a jQuery Ajax Call

In this JavaScript tutorial, you will read and learn detailed information about the method used for managing a redirect request after a jQuery Ajax call.

How to Measure Time Taken by a Function to Execute

Read this JavaScript tutorial and learn several fast and useful methods that are used to calculate the time taken by a function to execute in milliseconds.

How to Merge Properties of Two JavaScript Objects Dynamically

Have you ever wanted to merge the properties of two objects in JavaScript dynamically? This tutorial is aimed at showing you how to do it in rational ways.

How to Merge Two Arrays in JavaScript and De-duplicate Items

Read this tutorial and find useful information about the simplest methods that are used for merging two arrays and removing duplicate items in JavaScript.

How to Move an Array Element from One Array Position to Another

In this JavaScript tutorial, you will read and learn information about an easy insert strategy method of moving the array element to another position.

How to Pass a Parameter to a setTimeout() Callback

Read this JavaScript tutorial and learn the right way of passing a parameter to a setTimeout() callback. Also, get information about function binding.

How to Print a Circular Structure in a JSON-like Format

In this JavaScript tutorial, you will find useful information about the method that is used to format an object to JSON what contains circular structure.

How to Print a Message to the Error Console Using JavaScript

Read this tutorial and learn about the role of console object in JavaScript and, also, learn the way of printing the message to the error console easily.

How to Print JavaScript Console Using PHP

On this page, we will illustrate how to use PHP echo for printing JavaScript console. Here, you will find several options for different occasions.