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
Javascript Articles
Page 298 of 534
Change the Color of Link when a Mouse Hovers
To change the color of a link when a mouse pointer hovers over it, use the CSS :hover pseudo-class. This creates an interactive effect that provides visual feedback to users. Syntax a:hover { color: desired-color; } Basic Example Here's how to change a link's color on hover: a { ...
Read MoreHow to get the arctangent of the quotient of its arguments in JavaScript?
In this tutorial, we will learn how to get the arctangent of the quotient of its arguments in JavaScript. The JavaScript Math object provides built-in methods for mathematical operations. The Math.atan2() method is particularly useful for calculating the angle between two points in a coordinate system. Following are the ways to find the arctangent of the quotient of its arguments in JavaScript. Using Math.atan2() Method The Math.atan2() method returns a numeric value between -π and π representing the angle (in radians) between the positive x-axis and the point (x, y). Note that the y-coordinate is passed ...
Read MoreSet width between table cells with CSS
The border-spacing CSS property controls the distance between adjacent table cells. It only works when border-collapse is set to separate (the default value). Syntax border-spacing: horizontal vertical; border-spacing: value; /* same for both directions */ Parameters The property accepts one or two length values: One value: Sets equal spacing horizontally and vertically Two values: First value for horizontal spacing, second for vertical spacing Example: Basic Border Spacing table.example { ...
Read MoreHow to get the smallest integer greater than or equal to a number in JavaScript?
In this tutorial, we will learn how to get the smallest integer greater than or equal to a number in JavaScript. To get the smallest integer greater than or equal to a number, use the JavaScript Math.ceil() method. This method returns the smallest integer greater than or equal to a given number by rounding up to the nearest integer. The Math.ceil() method is a static function of the Math object and must be invoked as Math.ceil(). It always rounds numbers upward, making it perfect for finding the ceiling value of any number. Syntax Math.ceil(value) ...
Read MoreHow to get the largest integer less than or equal to a number in JavaScript?
In this tutorial, we will learn how to get the largest integer that can be less than or equal to a number in JavaScript. To get the largest integer less than or equal to a number, we use the Math.floor() method in JavaScript. It rounds down a number to its nearest integer towards the lower value, regardless of the decimal portion. Following are two ways to find the largest integer that can be less than or equal to a number in JavaScript. Using Math.floor() Method The Math.floor() method returns the greatest integer that is less than ...
Read MoreHow to get the largest of zero or more numbers in JavaScript?
In this tutorial, we will look at how to get the largest of zero or more numbers in JavaScript. The maximum of multiple numbers can be found using different techniques. The first technique we will introduce is the Math.max() method. The second technique will be the for-loop method. Following are the methods to get the largest of zero or more numbers in JavaScript − Using the Math.max() Method We can use the Math.max() method to find the largest of many numbers. It returns the largest value from the given multiple values. The input parameters should be ...
Read MoreHow to get the tangent of a number in JavaScript?
In this tutorial, we will learn how to get the tangent of a number in JavaScript. The tangent of an angle is defined by the ratio of the length of the opposite side to the length of the adjacent side. It can also be defined as the ratio of sine and cosine function of an acute angle where the value of cosine function should not be zero. Mathematically: tan θ = opposite side / adjacent side also, tan θ = sin θ / cos θ Where θ = angle in radians The tangent of a ...
Read MoreHow to convert a negative number to a positive one in JavaScript?
This tutorial will teach us to convert negative numbers to positive ones. Sometimes, programmers need to perform operations with the unsigned value of a number, and in such cases, they need to convert negative numbers to positive numbers. We will explore three different methods to convert negative numbers to positive numbers in JavaScript: Using the Math.abs() Method Multiplying the negative number with -1 Using the Bitwise Not Operator Using the Math.abs() Method The Math.abs() method is the most commonly used approach. It ...
Read MoreRegular expression to match numbers only in JavaScript?
In this tutorial, we will learn regular expressions to match numbers only in JavaScript. Data validation is essential for web applications. We often need to ensure users provide correct input — for example, phone numbers should contain only digits, or credit card fields should accept numbers only. Regular expressions provide a powerful way to validate and extract numeric data from strings. They use patterns to match specific character types and return the matched results. Understanding Regular Expression Patterns A regular expression consists of a pattern and optional modifiers. For matching numbers, we use: \d ...
Read MoreHow do we use throw statement in JavaScript?
In this tutorial, we will learn to use the throw statement in JavaScript. The "throw" is a reserved keyword in JavaScript that allows programmers to create user-defined exceptions. Every programmer makes errors, and sometimes users enter invalid input that causes exceptions. While JavaScript has built-in exceptions like arithmetic and index out-of-bound exceptions, programmers often need to create custom exceptions using the throw statement inside try...catch blocks. Below, we have given different examples of using the throw keyword in JavaScript. Using the throw keyword to create exception In this section, we will learn to create simple user-defined ...
Read More