Javascript Articles

Page 492 of 534

How to add 2 hours to a JavaScript Date object?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 29K+ Views

In this tutorial, we will learn how to add 2 hours to a JavaScript Date object. Here we will discuss two methods which are following. Using the getTime() Method Using the setHours() Method Using the getTime() Method JavaScript date getTime() method returns the numeric value corresponding to the time for the specified date according to universal time. The value returned by the getTime() method is the number of milliseconds since 1 January 1970 at 00:00:00. Syntax Date.getTime() Approach To add 2 hours to the Date Object first, we get ...

Read More

Create editable content in an HTML document

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 880 Views

The contenteditable attribute in HTML allows users to directly edit content on a webpage. This creates interactive elements that behave like text editors within the browser. Syntax The contenteditable attribute can be applied to any HTML element: Values true - Makes the element editable by the user false - Prevents the element from being edited (default behavior) Basic Example Here's a simple demonstration of editable vs non-editable content: Editable Content Demo This content is editable. Click here ...

Read More

How to find the value of a button with JavaScript?

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

In this tutorial, we will learn how to find the value of a button with JavaScript. Button elements often have a value attribute that stores important data for form processing or identification purposes. JavaScript provides the value property to access this attribute programmatically. Understanding how to retrieve button values is essential when working with HTML forms and interactive web applications. Button value Property The button value property returns the value of the value attribute assigned to a button element. This property is commonly used to distinguish between multiple buttons or pass specific data when forms are submitted. ...

Read More

How to remove event handlers in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 30K+ Views

An event is defined as a change in an object's state. There are a number of events in HTML that show when a user or browser performs a certain action. JavaScript responds to these events when JavaScript code is embedded in HTML and allows execution. The process of responding to events is known as event handling. As a result, JavaScript uses event handlers to handle HTML events. In this article, we are going to discuss how to remove event handlers in JavaScript. Here, we use the removeEventListener() method to remove an event handler from an element in JavaScript. ...

Read More

How to count JavaScript array objects?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 26K+ Views

In this tutorial, we will learn to count JavaScript array objects. The array is the data structure containing the strings, numbers, objects, etc., in JavaScript. The object is the one kind of entity that contains properties and methods related to it. We can access the object's properties and invoke the object method using the object's references. Generally, To find the array length, we can use the array.length property and it returns the total number of elements that the array includes. But what if we need to count only object elements? Here, this tutorial has various approaches to counting ...

Read More

How to format a number with two decimals in JavaScript?

Kumar Ishan
Kumar Ishan
Updated on 15-Mar-2026 102K+ Views

This tutorial will teach us how to format a number with two decimals using JavaScript. Formatting a number means rounding the number up to a specified decimal place. In JavaScript, we can apply many methods to perform the formatting. Some of them are listed as follows − The toFixed() Method Math.round() Method Math.floor() Method Math.ceil() Method Using toFixed() Method (Recommended) The toFixed() method formats a number with a specific number of digits to the right of the decimal. It returns a string representation ...

Read More

Use HTML with jQuery to make a form

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 2K+ Views

To create forms with HTML and jQuery, you can either write static HTML forms or dynamically generate them using jQuery's DOM manipulation methods. Creating a Static HTML Form The basic approach uses standard HTML form elements: Student Details: Student Name: ...

Read More

How to copy text to the clipboard with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 679 Views

To copy text to the clipboard in JavaScript, we can use both modern and legacy approaches. The modern navigator.clipboard API is recommended, while the older document.execCommand() method provides fallback support. Modern Approach: Using navigator.clipboard API The navigator.clipboard.writeText() method is the modern standard for copying text. It returns a Promise and works asynchronously. button { border: none; ...

Read More

ffmpeg settings for converting to mp4 and ogg for HTML5 video

Samual Sam
Samual Sam
Updated on 15-Mar-2026 2K+ Views

Convert videos to proper formats for HTML5 video on Linux shell using ffmpeg. HTML5 video requires specific codecs for cross-browser compatibility. MP4 with H.264/AAC works in most browsers, while OGV with Theora/Vorbis supports Firefox and other open-source browsers. Converting to MP4 Format When converting to MP4, use the H.264 video codec and AAC audio codec for maximum browser compatibility, especially IE11 and earlier versions. ffmpeg -i input.mov -vcodec h264 -acodec aac -strict -2 output.mp4 This command converts input.mov to output.mp4 with H.264 video and AAC audio codecs. MP4 with Maximum Compatibility ...

Read More

Hidden Bootstrap class

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 2K+ Views

To hide elements in Bootstrap, you can use visibility utility classes. Bootstrap provides several classes to control element visibility across different screen sizes and contexts. Bootstrap Hidden Classes Bootstrap offers different approaches to hide elements: .d-none - Completely removes the element from the document flow .visually-hidden - Hides visually but keeps accessible to screen readers .invisible - Makes element invisible but maintains its space Using .d-none Class The .d-none class completely hides an element by setting display: none: Bootstrap ...

Read More
Showing 4911–4920 of 5,340 articles
« Prev 1 490 491 492 493 494 534 Next »
Advertisements