Style text in div tag by javascript

Style text in div tag by javascript code:
...................................................
<html>
<head>
<title>Style text in div by javascript code</title>

<script type="text/javascript">

function styletext()
{

d=document.getElementById("divid"); //reference to div tag
d.innerHTML="This is a tip of JavaScript code to style text in div."; //put text in div
d.style.backgroundColor="#28aade"; //div background color
d.style.color="#ffffff";//set div text color
d.style.textAlign="center"; //specify div text alignment
d.style.fontWeight="bold"; //set font weight of text to bold
d.style.fontStyle="italic"; //make text in div italic
}

</script>

</head>
<body onload="styletext()">
<div id="divid"></div>
</body>
</html>

Posted by: balaya | post date: 11-18-2012 | Subject: JavaScript




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.