var $tables = $(twoTables);
$('#div1').append( $tables[0] );
$('#div2').append( $tables[1] );
Example: http://jsfiddle.net/VhAzV/
Since twoTables
represents an HTML string of 2 sequential tables, just send the string to a jQuery object, then select each table DOM element by its zero based index.
Or you could use .eq()
to get the table wrapped in a jQuery object.
var $tables = $(twoTables);
$tables.eq(0).appendTo('#div1');
$tables.eq(1).appendTo('#div2');
Here's a no jQuery version that still uses the browser's native HTML parser:
Example: http://jsfiddle.net/patrick_dw/VhAzV/2/
var twoTables = '<table><tr><td>table one</td></tr></table><table><tr><td>table two</td></tr></table>';
var $tables = document.createElement('div');
$tables.innerHTML = twoTables;
document.getElementById('div1').appendChild($tables.firstChild);
document.getElementById('div2').appendChild($tables.firstChild);
EDIT: Made it truly no-jQuery in the DOM insertion.