javascript - Extract outerHTML variable from $table -
i have not been able find information this, forgive lack of knowledge. created table using code below, want use table jquery plugin in order need print out table, mean
<table> <tr> . . .
i not sure how text. tried printing $table console, gives me object , properties. part of object outerhtml, need. can extract outerhtml? can stringify or print text $table without being object?
thanks
var columns = ["username","user_id","address","state","postal_code","phone","email"]; var level_classes = {"new":"new_client", "renewal":"renewing_client", "current":"current_client"}; $(document).ready( function() { $.getjson("obtainusers.php", function(data) { var $table = $('<table style="width: 100%;">'); var $tbody = $('<tbody>'); $table.append($tbody); var $tr = null; data.foreach(function(user, index){ if(index % 4 === 0) { $tr = $('<tr>'); $tbody.append($tr); } $td = $('<td class="'+level_classes[user.level]+'">'); columns.foreach(function(col){ $td.append(user[col]); $td.append($('<br>')); }); $tr.append($td); }); $('.runninglist').append($table); }); });
use .html()
print outerhtml node. @ted.
Comments
Post a Comment