With a little help from another forum I found a way to add a new element to a document using a javascript function and then hide the element (DIV) with another function. I share the code as it may be helpful for other users:
<html>
<head>
<script type="text/javascript">
function createDIV() {
t = document.createTextNode ('Fee, fie, foe and fum.')
p = document.createElement ("<div id='x'></div>")
p.appendChild (t)
body = document.getElementsByTagName ('BODY')[0]
body.appendChild (p)
}
function hideDIV() {
document.getElementById('x').style.display = 'none';
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<input type="button" name="Button" value="Create DIV" onclick="createDIV()">
<input type="button" name="Button" value="Hide DIV" onclick="hideDIV()">
</form>
</body>
</html>