Clearing an Elements DOM

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Clearing an Elements DOM

Post by iknownothing »

Hey All,
Dont know if the topic title is accurate, but here it goes anyway. I have a textbox in which a user can insert a number and something happens. What I want is to clear all the stuff that has appeared when the textbox value is taken away again.

Thanks.

This is the original action:

Code: Select all

function addElement() {
var numba = document.getElementById('calculator').value;
if (numba > 10) {
	
	$('<div style="height:30px;" valign="center" align="center">').append($('<font style="font-family:arial,verdana,sansserif;color:#FFFFFF;font-size:12px">Please enter in a value between 1 and 10</font>')).appendTo("#calcform").attr('id','Div'+counta);
}
var counta = 0;
while (counta < numba) {
	

	$('<div style="height:30px;" valign="center" align="center">').append($('<input type="text" size="8" />')).appendTo("#calcform").attr('id','Div'+counta);
	
	
counta++;
}
document.getElementById('calculator').value = "";
}
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I tend to create a basic registry for things like this and just clear out what's in the registry, or a specific item from the registry.
Post Reply