Javascript DOM Element class set

Description

Javascript DOM Element class set

View in separate window


<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <title>Chapter 9, Example 5</title> 
    <style> 
        #divAdvert { //from   w  ww. j  a v a  2s .  c o m
            font: 12pt arial; 
        } 

         .new-style { 
            font-style: italic; 
            text-decoration: underline; 
        } 
    </style> 

</head> 
<body> 
    <div id="divAdvert"> 
        Here is an advertisement. 
    </div> 

    <script> 
        let divAdvert = document.getElementById("divAdvert"); 
        divAdvert.className = "new-style"; 
    </script> 

</body> 
</html> 



PreviousNext

Related