border

In this chapter you will learn:

  1. Change the border of an element in Javascript

Change the border

<!DOCTYPE HTML> <!--from j  av  a  2 s  .co  m-->
<html> 
    <body> 
        <p id="myText"> 
            <span id="mySpan">HTML</span> 
            This is a test.
            This is a test.
        </p> 
        <p id="myPara"> 
            This is a test.
            This is a test.
            This is a test.
        </p> 
        <script> 
            var elems = document.getElementsByTagName("p"); 
            for (var i = 0; i < elems.length; i++) { 
              elems[i].style.border = "medium double black"; 
            } 
            
        </script> 
    </body> 
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to change padding for a HTML element from Javascript
Home » Javascript Tutorial » CSS
CSSStyleDeclaration Objects
border
padding
cssText
color
getComputedStyle
getPropertyValue
getPropertyCSSValue
getPropertyPriority