Skip to content
Permalink
Browse files

It's now possible to add <td>s and <th>s to a table, using only HTML.

  • Loading branch information
jeresig committed Jun 16, 2006
1 parent 894fc4b commit cb3eada739ce377f80408abe2103c95d5a016918
Showing with 12 additions and 2 deletions.
  1. +12 −2 jquery/jquery.js
@@ -408,15 +408,25 @@ $.clean = function(a) {
var r = [];
for ( var i = 0; i < a.length; i++ ) {
if ( a[i].constructor == String ) {
if ( a[i].indexOf("<tr") == 0 ) {

if ( !a[i].indexOf("<tr") ) {
var tr = true;
a[i] = "<table>" + a[i] + "</table>";
} else if ( !a[i].indexOf("<td") || !a[i].indexOf("<th") ) {
var td = true;
a[i] = "<table><tbody><tr>" + a[i] + "</tr></tbody></table>";
}

var div = document.createElement("div");
div.innerHTML = a[i];
if ( tr ) {

if ( tr || td ) {
div = div.firstChild.firstChild;
if ( td ) {
div = div.firstChild;
}
}

for ( var j = 0; j < div.childNodes.length; j++ ) {
r[r.length] = div.childNodes[j];
}

0 comments on commit cb3eada

Please sign in to comment.
You can’t perform that action at this time.