Javascript Articles - Page 558 of 671

How to set listStyleImage, listStylePosition, and listStyleType in one declaration with JavaScript?

Sharon Christine
Updated on 23-Jun-2020 13:03:09

119 Views

To set the list properties in a single declaration, use the listStyle property in JavaScript.ExampleYou can try to run the following code to set the listStylePosition and listStyleType property in one declaration with JavaScript −Live Demo                    One          Two             Change style                function display() {             document.getElementById("myID").style.listStyle = "circle outside";          }          

How to set the space between characters in a text with JavaScript?

Samual Sam
Updated on 23-Jun-2020 13:05:42

445 Views

To set the space between characters, use the JavaScript letterSpacing property.ExampleYou can try to run the following code to set the space between characters in a text with JavaScript −Live Demo           Heading 1       This is Demo Text.       Set Space between characters                function display() {             document.getElementById("myID").style.letterSpacing = "7px";          }          

How to deal with Internet Explorer and addEventListener problem "Object doesn't support this property or method" in JavaScript?

George John
Updated on 23-Jun-2020 13:05:00

2K+ Views

To deal with “Object doesn’t support this property or method” issue in JavaScript, while using events and Internet Explorer, update your code with this −Example                      ...     You can also use attachEvent in IE to solve this issue like this −if (ev.addEventListener) {    ev.addEventListener('click', myText, false); } else if (ev.attachEvent) {     ev.attachEvent('onclick', myText); }

What is the easiest code for array intersection in JavaScript?

Srinivas Gorla
Updated on 23-Jun-2020 13:03:41

126 Views

For array intersection, you can try to run the following code in JavaScript −Example                    let intersection = function(x, y) {             x = new Set(x), y = new Set(y);             return [...x].filter(k => y.has(k));          };          document.write(intersection([5,7,4,8], [3,9,8,4,3]));          

How to preserve the readability of text when font fallback occurs with JavaScript?

Kumar Varma
Updated on 23-Jun-2020 13:06:14

183 Views

Use the fontSizeAdjust property to preserve the readability of text. It sets the aspect value of a font i.e. the difference between the size of lowercase and uppercase letters.ExampleYou can try to run the following code to preserve the readability of text when font fallback occurs with JavaScript −Live Demo           Heading 1                This is Demo Text.             Set Aspect Value                function display() {             document.getElementById("myID").style.fontFamily = "verdana,sans-serif";             document.getElementById("myP").style.fontSizeAdjust = "0.90";          }          

How to set the height of an element with JavaScript?

Lakshmi Srinivas
Updated on 23-Jun-2020 13:06:43

779 Views

Use the height property to set the height of an element. You can try to run the following code to set the height of a button with JavaScript −ExampleLive Demo           Heading 1       This is Demo Text.       Update Height                function display() {             document.getElementById("myID").style.height = "100px";          }          

How to set the boldness of the font with JavaScript?

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

150 Views

Use the fontWeight property in JavaScript to set the font boldness.ExampleYou can try to run the following code to set the boldness of the font with JavaScript −Live Demo           Heading 1                This is Demo Text.             Set Font Family and Font Weight                function display() {             document.getElementById("myID").style.fontFamily = "verdana,sans-serif";             document.getElementById("myID").style.fontWeight = "800";          }          

What's the best way to detect a 'touch screen' device using JavaScript?

Chandu yadav
Updated on 23-Jun-2020 13:08:10

728 Views

The best way to detect a ‘touch screen’ device, is to work around to see whether the touch methods are present within the document model or not.function checkTouchDevice() {    return 'ontouchstart' in document.documentElement; }Here, you can also use it to detect mobile or desktop, like the following −if (checkTouchDevice()) {    // Mobile device } else {    // Desktop }

How to set height equal to the dynamic width (CSS fluid layout) in JavaScript?

Rishi Rathor
Updated on 23-Jun-2020 13:04:18

671 Views

To set height equal to the dynamic width in JavaScript, you can try to run the following code −Example                    .wrap {             width:400px;             height:300px;             border:2px solid yellow;          }          .myChild{             width: 80%;             border:1px solid red;          }                                  var res = $('.myChild').width();          $('.myChild').css({             'height': res + 'px'          });                                        

How to set whether the style of the font is normal, italic or oblique with JavaScript?

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

133 Views

To set the style of the font, use the fontStyle property. You can try to run the following code to set the style of the font to normal, italic or oblique with JavaScript −ExampleLive Demo           Heading 1                This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.          This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.             Set Font Family and Style                function display() {             document.getElementById("myID").style.fontFamily = "verdana,sans-serif";             document.getElementById("myID").style.fontStyle = "italic";          }          

Advertisements