Thứ Tư, 20 tháng 8, 2014

Changing "CSS" styles using "JAVASCRIPT"

It's very simple to change css styles using javascript.First you need to get object of DOM i'e you need to have a document object element,Finally change document element style using document.style."cssproprty"

example;

am just taken a sample text ,i changes the color of text into red by using css property color='red'.


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Changing Style</title>
<script type="text/javascript">
function data()
{
document.getElementById('content').style.color='red';
}
</script>
</head>
<body onload="data()">
<center><i id="content">This information is accessed via javascript</i></center>

</body>
</html>
output
===========


Không có nhận xét nào:

Đăng nhận xét