Javascript Articles - Page 557 of 671

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

Lakshmi Srinivas
Updated on 24-Jan-2020 06:37:27

1K+ Views

Use the marginTop property in JavaScript, to set the top margin. Can you try to run the following code to set the top margin of an element with JavaScript?ExampleLive Demo                    #myID {             border: 2px solid #000000;          }                     This is demo text.       Add top margin                function display() {             document.getElementById("myID").style.marginTop = "150px";          }          

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

karthikeya Boyini
Updated on 23-Jun-2020 13:18:11

755 Views

Use the marginBottom property in JavaScript, to set the bottom margin.ExampleYou can try to run the following code to set the bottom margin of an element with JavaScript −Live Demo           This is demo text.       Set bottom margin                function display() {             document.getElementById("myID").style.marginBottom = "95px";          }          

How to set the list-item marker type with JavaScript?

Fendadis John
Updated on 23-Jun-2020 13:18:44

486 Views

To set the type of the list-item marker type, use the listStyleType property. The marker type can be square, circle, dic, etc.ExampleYou can try to run the following code to set the list-item marker type with JavaScript −Live Demo                    One          Two             Update list style type (square)       Update list style type (decimal)                function displaySquare() {             document.getElementById("myID").style.listStyleType = "square";          }          function displayDecimal() {             document.getElementById("myID").style.listStyleType = "decimal";          }          

How to set the margins of an element with JavaScript?

Swarali Sree
Updated on 23-Jun-2020 13:19:12

271 Views

Use the margin property in JavaScript, to set the margins. You can try to run the following code to set the margins of an element with JavaScript −ExampleLive Demo           Set all four margins       This is demo text.                function display() {             document.getElementById("myID").style.margin = "30px 20px 40px 40px";          }          

How to set the maximum height of an element with JavaScript?

Sai Subramanyam
Updated on 23-Jun-2020 13:20:09

737 Views

Use the maxHeight property in JavaScript to set the maximum height. You can try to run the following code to set the maximum height of an element with JavaScript −ExampleLive Demo    #box {       width: 300px;       background-color: gray;       overflow: auto;    } Click below to set Maximum height. Max Height This is a div. This is a div. This is a div. This is a div. This is a div. This is a div. This is a div. This is a div. This is ... Read More

How to set the position of the list-item marker with JavaScript?

Jai Janardhan
Updated on 23-Jun-2020 13:20:40

214 Views

To set the position of the marker of the list-item, use the listStylePosition property. You can try to run the following code to set the position of the list-item marker with JavaScript −ExampleLive Demo                    One          Two             Add list inside       Add list outside                function displayInside() {             document.getElementById("myID").style.listStylePosition = "inside";          }          function displayOutside() {             document.getElementById("myID").style.listStylePosition = "outside";          }          

How to set an image as the list-item marker with JavaScript?

Monica Mona
Updated on 23-Jun-2020 13:21:08

165 Views

To set an image as the marker in list-item, use the listStyleImage property in JavaScript.ExampleYou can try to run the following code to set an image as the list-item marker with JavaScript −Live Demo                    One          Two             Update list image                function display() {             document.getElementById("myID").style.listStyleImage = "url('http://tutorialspoint.com/css/images/bullet.gif')";          }          

What is JavaScript garbage collection?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:21

355 Views

JavaScript automatically allocates memory, while a variable is declared. Garbage collection finds memory no longer used by the application and releases it since it is of no use. Garbage collector uses algorithms like Mark-and-sweep algorithm, to find the memory no longer used.This algorithm is used to free memory when an object is unreachable. The garbage collector identifies the objects, which are reachable or unreachable. These unreachable objects get the treatment from the automatic garbage collector.The Reference-Counting Garbage Collection is also used for garbage collection in JavaScript. The object will get automatically garbage collected if there are no references to it. ... Read More

How to workaround Objects vs arrays in JavaScript for key/value pairs?

Chandu yadav
Updated on 23-Jun-2020 13:21:48

190 Views

Store it like the following −var players = {    600 : 'Sachin',    300 : 'Brad', };For key/ value pairs, we have used the above solution, since we wanted a one-to-one. We did this to use the key as a lookup key. You can also add more values like this −var players = {    900 : 'Sachin',    300 : 'Brad',    700 : 'Steve',    200 : 'Rahul',    600 : 'Kevin',    500 : 'David', }

How to set the distance between lines in a text with JavaScript?

Paul Richard
Updated on 23-Jun-2020 13:22:18

477 Views

To set the distance between lines, use the lineHeight property. You can try to run the following code to set the distance between lines in a text with JavaScript −ExampleLive Demo           Heading 1       This is Demo Text.This is Demo TextThis is Demo Text       Set distance between lines                function display() {             document.getElementById("myID").style.lineHeight = "2";          }          

Advertisements