]> source.dussan.org Git - jquery.git/commitdiff
It's now possible to add <td>s and <th>s to a table, using only HTML.
authorJohn Resig <jeresig@gmail.com>
Fri, 16 Jun 2006 00:33:55 +0000 (00:33 +0000)
committerJohn Resig <jeresig@gmail.com>
Fri, 16 Jun 2006 00:33:55 +0000 (00:33 +0000)
jquery/jquery.js

index fafed0ea0b3428f300a296e5b7862f6fcb8fb5ee..9cf694105487e85faee86abe03ef02b6847f44af 100644 (file)
@@ -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];
                        }