Javascript Articles

Page 9 of 534

How to get current date/time in seconds in JavaScript?

Abhinanda Shri
Abhinanda Shri
Updated on 11-Mar-2026 737 Views

To convert time in seconds, firstly get the current time. Then, multiply the hours to 3600 and minutes to 60; rest you can see below −(hours*3600) + (min*60) + secExampleYou can try to run the following code to get the current time in seconds −           JavaScript Get Seconds                        var dt = new Date();          var sec = dt.getSeconds();          document.write("Seconds: " + sec);          var min = dt.getMinutes();          document.write("Minutes: " + min);          var hrs = dt.getHours();          document.write("Hours: " + hrs);          var total_seconds = (hrs*3600) + (min*60) + sec;          document.write("Total seconds: " + total_seconds) ;           OutputSeconds: 35 Minutes: 37 Hours: 9 Total seconds: 34655

Read More

How to get Euler's constant value in JavaScript?

Kumar Varma
Kumar Varma
Updated on 11-Mar-2026 891 Views

To get Euler’s constant value in JavaScript, use the Math E property. This is a Euler's constant and the base of natural logarithms, approximately 2.718.ExampleYou can try to run the following code to get Euler’s constant value in JavaScript −           JavaScript Math E Property                        var property_value = Math.E          document.write("Property Value is :" + property_value);           OutputProperty Value is :2.718281828459045

Read More

How to get Natural logarithm of 2 in JavaScript?

Paul Richard
Paul Richard
Updated on 11-Mar-2026 548 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 788 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 609 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 218 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 548 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 263 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 162 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
Showing 81–90 of 5,339 articles
« Prev 1 7 8 9 10 11 534 Next »
Advertisements