ava script tutorial - a new approach by Ken J Ward

Java Script Tutorial -


Deleting Text

The first button here, "Modify Text", relates to the previous lesson. Click on the second button and notice what happens to the paragraph below ("First text").




First text

The text, "First text", is deleted as expected.

The code for this is almost the same as the code for modifying text. The difference is that the node value is set to nothing ("").

function deleteText()

{

var para = document.getElementById('myPara1');

para.lastChild.nodeValue ="";

}

The rest of the code for the paragraph is the same as the previous lesson's.

[If you need to learn more about HTML visit the HTML Tutorial]

I am always pleased to hear from you.
Send your comments to