diff options
author | John Resig <jeresig@gmail.com> | 2006-06-16 00:33:55 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2006-06-16 00:33:55 +0000 |
commit | cb3eada739ce377f80408abe2103c95d5a016918 (patch) | |
tree | 428ecde6e5b71457f0fa824b7b43cf0e4511da01 /jquery | |
parent | 894fc4b280b9ea967a4da08ce6b26462837b033f (diff) | |
download | jquery-cb3eada739ce377f80408abe2103c95d5a016918.tar.gz jquery-cb3eada739ce377f80408abe2103c95d5a016918.zip |
It's now possible to add <td>s and <th>s to a table, using only HTML.
Diffstat (limited to 'jquery')
-rw-r--r-- | jquery/jquery.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/jquery/jquery.js b/jquery/jquery.js index fafed0ea0..9cf694105 100644 --- a/jquery/jquery.js +++ b/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]; } |