Using JavaScript to change CSS Properties
CSS & Javascript February 9th, 2007I’ve created a mixture of Javascript and CSS codes to change the location attribute of an image.
The picture can be dynamically changed without reloading the page. This is very good example if you are planning to create a CSS element and change its properties without loading the entire page.
As per usual, this code only work with browsers that support DOM. Basically, there is number of things of CSS properties can be changed. My example is only to change the top and left property respectively.
A short example of changing the CSS property using javascript is being described below.
<script type=”text/javascript”>
function changeCssProp() {
document.getElementById(”contentDiv”).style.display = “none”;
}
</script><div id=”contentDiv” style=”display: block“>Some Text</div>
You can see more demo at this page.
Complete zipped file is available here.
I’ve done it.


