Programming Articles

Page 886 of 2547

How to stop form submission using JavaScript?

Abhishek
Abhishek
Updated on 15-Mar-2026 63K+ Views

In this tutorial, we will see the methods to stop form submission using JavaScript. Generally, the HTML form by default submits automatically when certain events are triggered. The automatic submission causes the browser to refresh and reload the whole page, which we don't want in some cases. To perform any operation before submission, we need to change the default behavior of the form to prevent it from submitting. Following are the methods we can use to stop form submission: Using the "return false" value Using the preventDefault() method Let ...

Read More

How to display output in javascript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 3K+ Views

JavaScript provides several methods to display output to users. Here are the four most common approaches for displaying data in web applications. Using innerHTML to Display in HTML Elements The innerHTML property allows you to insert content directly into HTML elements on your webpage. document.getElementById("demo").innerHTML = "Hello, World!"; Hello, World! Using document.write() Method The document.write() method writes content directly to the HTML document. ...

Read More

Write the syntax of javascript with a code to demonstrate it?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 274 Views

JavaScript Tags JavaScript code must be placed within HTML tags to execute properly. These script tags can be positioned in different locations within an HTML document. Where to Place JavaScript JavaScript can be embedded in three main locations: Head section: Scripts in the tag load before the page content Body section: Scripts in the tag execute as the page loads External file: Scripts can be linked from separate .js files Basic JavaScript Syntax JavaScript syntax includes variables, functions, and DOM ...

Read More

What are the types of tags involved in javascript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 1K+ Views

In JavaScript, there are several types of HTML tags that work with JavaScript code. The most important is the tag, which is essential for embedding or linking JavaScript in web pages. HTML Tag The tag is used to define client-side scripts in HTML documents. It can contain JavaScript code directly or reference an external JavaScript file. All JavaScript code must be placed within tags to be executed by the browser. Types of Script Tags Inline JavaScript JavaScript code written directly inside the tag: ...

Read More

What is the difference between Math.ceil() and Math.round() methods in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 6K+ Views

Math.ceil() and Math.round() are JavaScript methods that round numbers to integers, but they work differently. Math.ceil() always rounds up to the nearest integer, while Math.round() rounds to the nearest integer using standard rounding rules (0.5 and above rounds up, below 0.5 rounds down). Math.ceil() - Always Rounds Up The Math.ceil() method rounds a number up to the nearest integer, regardless of the decimal value. It always moves toward the greater value. Syntax Math.ceil(x) Example ...

Read More

How do we include the direction of text display in HTML?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 266 Views

Use the dir attribute in HTML to specify the text direction. This attribute controls whether text flows left-to-right (LTR) or right-to-left (RTL). Syntax content Attribute Values Value Description Use Case ltr Left-to-right English, French, German rtl Right-to-left Arabic, Hebrew, Urdu auto Browser determines direction Mixed language content Example Here's how to use the dir attribute for different text directions: Text Direction Example This is default left-to-right text. ...

Read More

What is function chaining in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 4K+ Views

Function chaining is a technique that allows you to call multiple methods on the same object in sequence using dot notation. This makes code more concise and improves readability by eliminating the need to repeatedly reference the same object. How Function Chaining Works For function chaining to work, each method must return the object itself (typically using return this). This allows the next method in the chain to be called on the returned object. Without Function Chaining In this example, the methods don't return this, so chaining is not possible: ...

Read More

Explain in detail about the memory life cycle of JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 479 Views

JavaScript's memory management is crucial for application performance. Understanding the memory lifecycle helps developers write more efficient code and avoid memory leaks. The Three Stages of Memory Lifecycle Every programming language follows a similar memory lifecycle with three fundamental stages: Allocation of memory - Reserve memory space for variables and objects Use the allocated memory - Read from and write to the allocated memory Release the allocated memory - Free up memory when it's no longer needed In low-level languages, developers manually handle allocation and deallocation. However, high-level languages like JavaScript manage this process ...

Read More

How to execute a cube of numbers of a given array in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 2K+ Views

To calculate the cube of each number in an array, you can use several approaches. The most common methods involve iterating through the array and applying the cube operation (n³) to each element. Using a for Loop The traditional approach uses a for loop to iterate through the array and replace each element with its cube: var numbers = [1, 2, 3, 4, 5]; // Calculate cube of each element for (var i = 0; i ...

Read More

How to get a part of string after a specified character in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 16K+ Views

To get a part of a string after a specified character in JavaScript, you can use the substring() method combined with indexOf(). This technique allows you to extract portions of text before or after any character. Understanding substring() The substring() method extracts characters from a string between two specified indices. It takes a start index (inclusive) and an optional end index (exclusive). Syntax for Getting Text After a Character string.substring(string.indexOf(character) + 1); Here, indexOf(character) finds the position of the character, and adding + 1 starts extraction from the next position. Syntax for ...

Read More
Showing 8851–8860 of 25,466 articles
« Prev 1 884 885 886 887 888 2547 Next »
Advertisements