Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Abhishek
Page 4 of 7
How to find the value of a button with JavaScript?
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 MoreHow to fill columns with JavaScript?
In this tutorial, we will learn how to fill columns with JavaScript using the columnFill property. This CSS property controls how content is distributed across multiple columns - either sequentially (auto) or with equal distribution (balance). The columnFill property specifies how columns should be filled when using CSS multi-column layout. It works in conjunction with columnCount to create responsive column layouts. Syntax Following is the syntax to set the columnFill property in JavaScript: selectedElement.style.columnFill = "value"; Here selectedElement is the DOM element you want to modify. The style property allows you to set ...
Read MoreHow to test if an element contains class in JavaScript in HTML?
In JavaScript, we can check whether an HTML element contains a particular class using the classList.contains() method. This is especially useful when working with dynamic content or when you need to conditionally apply styles or behavior based on an element's classes. The classList.contains() method is the standard and most reliable way to test for class existence on DOM elements. Syntax element.classList.contains(className) Parameters: className - A string representing the class name to check for Return Value: Returns true if the element contains the specified class, false otherwise. Example: Basic ...
Read MoreHow to subtract days from a date in JavaScript?
In JavaScript, you can subtract days from a date using built-in Date methods. The most common approaches are using setTime() with getTime() for millisecond-based calculation, or setDate() with getDate() for simpler day-based arithmetic. Following are the methods we can use to subtract days from a date in JavaScript: Using the setTime() and getTime() methods Using the setDate() and getDate() methods Using setTime() and getTime() Methods The setTime() method sets a date by milliseconds since ...
Read MoreHow to find the coordinates of the cursor with JavaScript?
In this tutorial, we will learn how to find the coordinates of the mouse cursor with JavaScript. We need to determine the X and Y coordinates (horizontal and vertical positions) of the cursor on the screen when mouse events occur. JavaScript provides us with two essential properties to get the coordinates of the mouse cursor when events are triggered: Using event.clientX Property Using event.clientY Property Using event.clientX Property The event.clientX property returns the horizontal position (X-coordinate) of the cursor relative to the browser's viewport when an event is ...
Read MoreHow to submit an HTML form using JavaScript?
In this tutorial, we will learn how to submit an HTML form using JavaScript. JavaScript provides multiple approaches to handle form submission, from direct programmatic submission to validation-based submission with user feedback. We will discuss two main methods for submitting HTML forms: Using the Form submit() Method Using Manual Validation Let us explore both methods with practical examples. Using the Form submit() Method The submit() method programmatically submits a form without requiring user interaction with the submit button. This method takes no parameters and returns no value—it ...
Read MoreHow to style background image to no repeat with JavaScript DOM?
In this tutorial, we will learn to style the background image to no repeat with JavaScript DOM. To style the background image to no repeat with JavaScript, use the backgroundRepeat property. It allows you to set whether the background image repeats or not on a page. The use of images in the background really makes the page attractive. But before using the image in the background, one must completely understand the properties used to set the images as the background. Otherwise, it will create problems like not showing the full image in the background, repeating the image horizontally or ...
Read MoreHow to use JavaScript DOM to change the padding of a table?
In this tutorial, we learn to use JavaScript DOM to change the padding of a table. To change the padding of a table, use the DOM padding property. The HTML table is used to display relational data on the user screen. We can easily show related or dependent data to the user and user can easily understand and determine the characteristics of the data with help of table. But, while we are showing the relational data to the user in the form of table, we need to make sure that the table is well structured and looking good according ...
Read MoreHow to use JavaScript to check if a number has a decimal place or it's a whole number?
In JavaScript, determining whether a number is a whole number or has decimal places is a common requirement. This tutorial explores three effective methods to accomplish this task using both built-in JavaScript methods and custom functions. The following methods are available to check if a number is decimal or whole: Using the Math.floor() Method Using the Number.isInteger() Method Using a Custom isDecimal() Function Using Math.floor() Method The Math.floor() method returns the largest integer less than or equal to a given number. By comparing the original number with its ...
Read MoreHow to find out which JavaScript events fired?
In this tutorial, we will learn how we can find out which JavaScript event is fired or triggered. We can add events to HTML elements to perform some actions on the webpage like changing text, form submission, etc. There are two ways of finding which JavaScript event is fired − Using Developer Tools Using Inspect Element Let us discuss both of them one by one with coding examples. Using Developer Tools We can find out which JavaScript event is fired by using developer tools in the browser. ...
Read More