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 327 of 534
How to set whether or not an element is resizable by the user with JavaScript?
In this tutorial, we will learn to set whether or not an element is resizable by the user with JavaScript. The CSS resize property controls if users can drag element corners to change its size. Web elements are typically fixed in position and size. However, sometimes you need to allow users to resize elements dynamically. The CSS resize property provides this functionality, and JavaScript's DOM manipulation allows us to control this behavior programmatically. Using the Style resize Property The resize property determines whether an element can be resized by the user. Common examples include textarea elements, which ...
Read MoreHow to set the type of quotation marks for embedded quotations with JavaScript?
In this tutorial, we will learn how to set the type of quotation marks for embedded quotations with JavaScript. The types of quotation marks can be changed using JavaScript. For example, if a sentence is in double quotes(""), it can be modified to single quotes(''). To set the quotation, use the element. With that, add the type of quotation marks with the quotes property. Using the quotes property to set the type of quotation marks In JavaScript, the quotes property is used to set the type of quotation marks for embedded quotations. The quotation marks can ...
Read MoreHow to set all the four border radius properties at once with JavaScript?
In JavaScript, you can set all four border-radius properties at once using the borderRadius property. This property allows you to apply rounded corners to an element by setting a single value or multiple values for different corners. Syntax The borderRadius property can accept different formats: element.style.borderRadius = "10px"; // All corners element.style.borderRadius = "10px 20px"; // top-left/bottom-right, top-right/bottom-left element.style.borderRadius = "10px 20px 30px"; // top-left, top-right/bottom-left, bottom-right element.style.borderRadius = "10px 20px 30px 40px"; // top-left, top-right, bottom-right, bottom-left Example: ...
Read MoreHow to get only the first n% of an array in JavaScript?
We are required to write a function that takes in an array arr and a number n between 0 and 100 (both inclusive) and returns the n% part of the array. Like if the second argument is 0, we should expect an empty array, complete array if it's 100, half if 50, like that. And if the second argument is not provided it should default to 50. Therefore, the code for this will be − Syntax const byPercent = (arr, n = 50) => { const requiredLength = Math.floor((arr.length * n) / ...
Read MoreHow to set all the border right properties in one declaration with JavaScript?
To set all the border right properties in JavaScript, use the borderRight property. This property allows you to set the border color, style, and width at once using a single declaration. Syntax element.style.borderRight = "width style color"; Parameters The borderRight property accepts a string value with three components: width - Border thickness (e.g., "2px", "thick", "thin") style - Border style (e.g., "solid", "dashed", "dotted") color - Border color (e.g., "#000000", "red", "rgb(255, 0, 0)") Example You can try to run the following code to learn how to set all ...
Read MoreFind average of each array within an array JavaScript
We are required to write a function getAverage() that accepts an array of arrays of numbers and we are required to return a new array of numbers that contains the average of corresponding subarrays. Let's write the code for this. We will map over the original array, reducing the subarray to their averages like this − Example const arr = [[1, 54, 65, 432, 7, 43, 43, 54], [2, 3], [4, 5, 6, 7]]; const secondArr = [[545, 65, 5, 7], [0, 0, 0, 0], []]; const getAverage = (arr) => { ...
Read MoreHow to set the color of the right border with JavaScript?
In this tutorial, we will learn how to set the color of the right border with JavaScript. To set the color of the right border in JavaScript, use the borderRightColor property. Set the color of the right border using this property. We can also apply the borderColor property to complete the task. The border is the outline of an HTML element. Border color can be set for different sides using different properties. To set the color of the right border with JavaScript, we have different ways − Using the style.borderRightColor Property ...
Read MoreHow to set the bottom padding of an element with JavaScript?
To set the bottom padding of an element in JavaScript, use the paddingBottom property of the element's style object. This property allows you to dynamically modify the spacing between an element's content and its bottom border. Syntax element.style.paddingBottom = "value"; Where value can be specified in pixels (px), percentages (%), em units, or other valid CSS length units. Example Here's how to set the bottom padding of an element dynamically: #box { ...
Read MoreRecursion in array to find odd numbers and push to new variable JavaScript
We are required to write a recursive function, say pushRecursively(), which takes in an array of numbers and returns an object containing odd and even properties where odd is an array of odd numbers from input array and even an array of even numbers from input array. This has to be done using recursion and no type of loop method should be used. Syntax const pushRecursively = (arr, len = 0, odd = [], even = []) => { // Base case: if we've processed all elements if (len ...
Read MoreHow to set the width of the top border with JavaScript?
In this tutorial, we will learn how to set the width of the top border with JavaScript. The border of an element is the outer part of the element. The border width for each side can be set with different JavaScript properties. For example, to set the width of the top border in JavaScript, use the borderTopWidth property. There are two approaches to specifying the width of the top border − Using the setProperty method Using the borderTopWidth property Using the setProperty Method In JavaScript, any property ...
Read More