innerHTML on a td element

innerHTML on a td element

rafis23rafis23 Posts: 6Questions: 0Answers: 0
edited December 2009 in General
Could someone possibly suggest why this code works...

var contraRow = aRow.cloneNode(true);
$('td:gt(13)', contraRow).remove() ;

...but this code does not...

var contraRow = aRow.cloneNode(true);
$('td:gt(13)', contraRow).innerHTML = " " ;

...I want to make those td elements blank, not delete them completely.

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi rafis23,

    If you want to make the TD element empty, then I would suggest that $().remove() is not the right thing to use, since it will delete the elements (according to the jQuery documentation). I think the situation might be getting confused by the cloneNode - remember that is operating on the cloned node, and to see the effect you would need to add that back into the DOM. Certainly putting a blank string into innerHTML will clear a node out.

    Possibly a question for the jQuery mailing list rather than DataTables, if this doesn't answer it :-)

    Regards,
    Allan
This discussion has been closed.