Posted by: prajapatinilesh | September 14, 2007

Removing all child nodes from an element

The HTML for the table cell could look something like this:
<td id="cell">$1.20</td>
Once the user clicks on a cell, the HTML of the cell changes to:
<td id="cell"><input type="text" value="$1.20" /></td>
var cell = document.getElementById(“cell”);
if ( cell.hasChildNodes() ) {
while ( cell.childNodes.length >= 1 ) {
cell.removeChild( cell.firstChild );
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: