JavaScript Tutorial

Define JavaScript

JS Arithmetic Exercise

JavaScript Comment

JavaScript Variable

JavaScript Operators

Conditional Statements

Logical Operators

JavaScript Slider

JS Login Form

JS Popup Boxes

JavaScript Loops

JavaScript Arrays

JS Mouse Events

JS Keyboard Events

Styling Elements

External JavaScript

JS Noscript Tag

JS String Functions

JS Math Functions

JS Random

JS Date Functions

theme-changer

JS Assignment

JS Question-Answer

Page Stats

Visitor: 406

CSS Styling using JavaScript

Example 1: Change the style of an HTML elements using javascript.

<html> 
   <script> 
      function myFunction() 
      { 
         var x = document.getElementById("demo"); 
         x.style.fontSize = "25px"; 
         x.style.color = "red"; 
      } 
   </script> 
   <body> 
      <p id="demo">
         JavaScript can change the style of an HTML element.
      </p> 
      <button type="button" onclick="myFunction()">
         Click Me!
      </button> 
   </body> 
</html>