Found 10483 Articles for Web Development

Set how the item will shrink relative to the rest with JavaScript?

Shubham Vora
Updated on 15-Nov-2022 10:30:43

296 Views

In this tutorial, let us look at the way to set how much the item will shrink relative to the rest of the elements in JavaScript. To set item shrink relative to the rest of the elements, we can utilize JavaScript's flexShrink property. Let's take a quick look at this. Using the Styel flexShrink Property The flexShrink property specifies how much a flex item will shrink according to the other items in the same container. The element must be flexible for the flexShrink property to function. The property's value functions as a ratio. For instance, 2:3 sets 2 to the ... Read More

How to set an element's display type with JavaScript?

Samual Sam
Updated on 23-Jun-2020 12:20:01

2K+ Views

To set an element’s display type, use the display property. If you want to hide the element, then use none.ExampleYou can try to run the following code to set an element's display type with JavaScript −Live Demo                    #myID {             width: 250px;             height: 200px;             background-color: green;          }                     Set display as none                Heading Level 1 for Demo          This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.                      function display() {             document.getElementById("myID").style.display = "none";          }          

How to set the type of cursor to display for the mouse pointer with JavaScript?

Shubham Vora
Updated on 12-Oct-2022 11:04:31

2K+ Views

In this tutorial, we will learn to set the type of cursor for the mouse pointer with JavaScript. To set the type of cursor, use the cursor property in JavaScript. It allows you to change the cursor on the button click. We can even change the type of cursor by using JavaScript. Different types of cursors have different meanings. There are many styles of cursors that can use on our webpage. Let us look at how to set the type of cursor to display for the mouse pointer with JavaScript. Using the Style cursor Property The cursor property is used ... Read More

How to set the direction of the flexible items with JavaScript?

Shubham Vora
Updated on 09-Nov-2022 11:36:02

1K+ Views

In this tutorial, we will learn how to set the direction of the flexible items with JavaScript. The direction of the flexible items can be set using the flex-direction property of CSS. It defines how the flexible items will be placed in the flex container. Its default value is set to ‘row’, but it can have other values like ‘column’, ‘row-reverse’ etc. To set the direction of the flexible items with JavaScript, we have multiple ways, and in this tutorial, we will discuss two of them − Using the style.flexDirection Property Using the style.setProperty Method Using the style.flexDirection ... Read More

How to increment one or more counters with JavaScript?

Shubham Vora
Updated on 12-Oct-2022 09:22:28

14K+ Views

In this tutorial, we will learn how to increment one or more counters with JavaScript. In JavaScript, we can increment one or more counters in different approaches, and in this tutorial, we will see some of the approaches for doing this − Using loop iteration Using events Using setInterval() method Increment Counters using Loop Iteration Counters can be easily incremented by using loop iterations. In JavaScript, we have multiple loops like the "for" loop and the "while" loop. We can use any one of them to increment a counter value. Firstly, we need to set a limit for ... Read More

How to set the initial length of a flexible item with JavaScript?

Shubham Vora
Updated on 15-Nov-2022 08:00:41

377 Views

In this tutorial, we will learn how to set the initial length of a flexible item with JavaScript. Flexbox is a one-dimensional layout model that distributes space among items in an interface and provides flexible item alignment properties. It creates flexible items. Use the flexBasis property in JavaScript to set the initial length of a flexible item. In this tutorial, we will see two approaches to setting the initial length of a flexible item − Using the property style.flexBasis Using the method style.setProperty Using the style.flexBasis Property The style flexBasis is a flexbox property that determines the initial ... Read More

How to create or reset counters with JavaScript?

karthikeya Boyini
Updated on 23-Jun-2020 12:25:14

879 Views

To create counters, use the counterReset property in JavaScript. You can try to run the following code to create or reset one or more counters with JavaScript −ExampleLive Demo                    h2:before {             counter-increment: section;             content: counter(section) " Quiz ";          }                     Quizzes       Change the counterIncrement       Ruby       Java       PHP       Perl       Reset Counter                function display() {             document.body.style.counterReset = "section";          }          

How to set the left margin of an element with JavaScript?

Shubham Vora
Updated on 15-Nov-2022 08:05:12

5K+ Views

In this tutorial, we will learn how to set the left margin of an element with JavaScript. Margin is the space around an element outside its border. The margin of an element can be on all sides, such as: left, right, top, and bottom. Use the marginLeft property in JavaScript to set the left margin. In this tutorial, we will discuss two approaches to setting the left margin − Using the marginLeft property Using the setProperty method Using the marginLeft property to set the left margin of an element The marginLeft property of an element in JavaScript is ... Read More

Set how many columns an element should span across with JavaScript.

Shubham Vora
Updated on 31-Oct-2022 11:55:27

356 Views

In this tutorial, we will learn to set how many columns an element should span across with JavaScript. Dividing long paragraphs or articles into many columns improves their readability. The ‘column-count’ CSS property divides the text into numerous columns. Set the columnSpan property to all if you want the columns to span across in JavaScript. To set how many columns an element should span across with JavaScript, we have multiple ways, and in this tutorial, we will discuss two of them − Set the columnSpan property Use the style.setProperty method Set the columnSpan Property In JavaScript, the columnSpan ... Read More

How to set column width and column count with JavaScript?

Vikyath Ram
Updated on 23-Jun-2020 12:16:55

751 Views

To set the column width and column count in a single declaration, use the JavaScript columns property.ExampleYou can try to run the following code to set column width and column count with JavaScript −                    #myID {             column-count: 4;             column-rule: 4px solid yellow;          }                     Click below to change the column count to 2 and minimum size       Change Column count and ... Read More

Advertisements