Javascript Articles

Page 6 of 534

How to get Natural logarithm of 2 in JavaScript?

Paul Richard
Paul Richard
Updated on 11-Mar-2026 547 Views

To get the Natural logarithm of 2, use the Math.LN2 property in JavaScript. It returns the natural logarithm of 2, which is approximately 0.693.ExampleYou can try to run the following code to get Natural logarithm of 2 −           JavaScript Math LN2 Property                        var property_value = Math.LN2          document.write("Property Value is : " + property_value);           OutputProperty Value is : 0.6931471805599453

Read More

How to create a two dimensional array in JavaScript?

Nikitha N
Nikitha N
Updated on 11-Mar-2026 784 Views

A two-dimensional array has more than one dimension, such as myarray[0][0] for element one, myarray[0][1] for element two, etc. To create a two-dimensional array in JavaScript, you can try to run the following code −Example                                        var myarray=new Array(3);                  for (i=0; i

Read More

How to show all the options from a dropdown list with JavaScript?

Sharon Christine
Sharon Christine
Updated on 11-Mar-2026 5K+ Views

To show all the options from a dropdown list, use the options property. The property allows you to get all the options with length property.ExampleYou can try to run the following code to get all the options from a drop-down list.                                 One             Two             Three                                 Click the button to get all the options                function display() {             var a, i, options;             a = document.getElementById("selectNow");             options = "";             for (i = 0; i < a.length; i++) {                options = options + " " + a.options[i].text;             }             document.write("DropDown Options: "+options);          }          

Read More

How to get the value of the type attribute of a link in JavaScript?

Paul Richard
Paul Richard
Updated on 11-Mar-2026 608 Views

To get the value of the type attribute of a link in JavaScript, use the type property. The type attribute is used to tell that the document is html (text/html) or css (text/css), etc.ExampleYou can try to run the following code to get the value of the type attribute of a link.           Qries                var myVal = document.getElementById("anchorid").type;          document.write("Value of type attribute: "+myVal);          

Read More

How to work with document.embeds in JavaScript?

Jai Janardhan
Jai Janardhan
Updated on 11-Mar-2026 217 Views

Use the document.embeds property in JavaScript to get the number of tags in a document.ExampleYou can try to run the following code to implement document.embeds property in JavaScript.           JavaScript Example                              var num = document.embeds.length;          document.write("How many embed tags: "+num);          

Read More

How to work with document.images in JavaScript?

Arushi
Arushi
Updated on 11-Mar-2026 546 Views

Use the document.images property in JavaScript to get the number of tags in a document.ExampleYou can try to run the following code to implement document.images property in JavaScript.           JavaScript Example               TutorialsPoint Tutorials                            var num = document.images.length;          document.write("How many images? "+num);          

Read More

How to set the shape of the border of the top-right corner with JavaScript?

Fendadis John
Fendadis John
Updated on 11-Mar-2026 262 Views

To set the shape of the border of the top-right corner in JavaScript, use the borderTopRightRadius property. Set border radius using this property.ExampleYou can try to run the following code to learn how to set the shape of the top-right border with JavaScript.                    #box {             border: thick solid gray;             width: 300px;             height: 200px          }                     Demo Text             Change top right border radius                function display() {             document.getElementById("box").style.borderTopRightRadius = "20px";          }          

Read More

How to set all the background properties in one declaration with JavaScript DOM?

Swarali Sree
Swarali Sree
Updated on 11-Mar-2026 160 Views

To set the background in JavaScript, use the background property. It allows you to set the background color, image, position, etc.ExampleYou can try to run the following code to learn how to set all the background properties in a single declaration with JavaScript.           Click to Set background                function display() {             document.body.style.background = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg') repeat right top";          }          

Read More

How to set the starting position of a background image in JavaScript DOM?

Sharon Christine
Sharon Christine
Updated on 11-Mar-2026 555 Views

To set the starting position of a background image in JavaScript, use the backgroundposition property. It allows you to set the position of the image.ExampleYou can try to run the following code to learn how to set all the position of a background image with JavaScript −                    body {             background-repeat: no-repeat;          }                     Click to Set background image                function display() {             document.body.style.backgroundImage = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg')";             document.body.style.backgroundPosition="top right";          }          

Read More

How to set all the border bottom properties in one declaration in JavaScript DOM?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 11-Mar-2026 189 Views

To set the border bottom properties in one declaration in JavaScript, use the borderBottom property. It allows you to set the border-bottom-width, border-bottom-style, and border-bottom-color.ExampleYou can try to run the following code to learn how to set border bottom properties −                    #box {             border: 2px dashed blue;             width: 120px;             height: 120px;          }                     Set border bottom color                Demo Text          Demo Text                      function display() {             document.getElementById("box").style.borderBottom = "thin dashed #000000";          }          

Read More
Showing 51–60 of 5,339 articles
« Prev 1 4 5 6 7 8 534 Next »
Advertisements