Tuesday, January 25, 2011


<html>
<head>
<title>A Simple Page </title>
<script type="text/javascript">
function modify() {
var newElem = document.createElement("p");
newElem.id = "newP";
var newText = document.createTextNode("This is the second paragraph.");
newElem.appendChild(newText);
document.body.appendChild(newElem);
document.getElementById('emphasis1').childNodes[0].nodeValue = 'first';
}

function addSomething() {
var newEdition = document.createElement("div");
newEdition.id ="newDiv";
var addText = document.createTextNode("Here is another additional text.");
newEdition.appendChild(addText);
document.body.appendChild(newEdition);
}
</script>
</head>
<body>
<button onclick="modify()">Add/Replace Text
<button onclick="addSomething()">Add Something else
<

<p id="paragraph1">This is the <em id="emphasis1">one and only </em> paragraph on the page. </p>


</body>
</html>


Advanced XHTML is a time-eater. Learning jQuery looks interesting though.

No comments: