Tuesday, June 14, 2011

Javascript to change text

Example:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

function htmlonload(){
changeText("MyText", "text changed");
}

function changeText(id, text){
document.getElementById(id).innerHTML = text;
}

</script>
<meta charset="UTF-8">
<title>Test Text: Javascript to change text</title>
</head>
<body onload="htmlonload();">
<h1>Test Text: Javascript to change text</h1>
<div id="MyText">Hello All</div>

</body>
</html>

Output:
Javascript to change text

No comments:

Post a Comment