There are several basic concepts which you need to understand in javascript.
First at all: the reference. Before trying to modify the status of an element, you need to refer it, a way or another. In javascript there are several methods to refer an element: by id, by name, by tagname, by the absolute or relative position in the DOM tree. In your case, probably the easier way to refer that paragraph element is by its tagname: It is the first <p><p/>element
Code:
var myElement=document.getElementsByTagName('p')[0];
Second: you must learn the javascript methods. For instance: removeChild(): the syntax is:
Code:
theParentNode.removeChild(theNode)
where theNode and theParentNode should be the references of the element and its parent node.
Third. In javascript the statements are nested in functions, functions are fired by events which follows the user's action. Now: which could be the event in your case?
Anyway, here's a basic example:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function removeEl(tag,n){
if(!document.getElementsByTagName(tag)[n]){return}//catch the error in case there is no element
var el=document.getElementsByTagName(tag)[n];
el.parentNode.removeChild(el);
}
</script>
</head>
<body>
<p>text</p>
<p>other text</p>
<br>
<br>
<span onclick="removeEl('p',0)">Remove the first paragraph</span>
</body>
</html>
Bookmarks