I am trying to prepend some HTML to an AJAX created table. Here is the code:
success: function (msg) {
var ang = '';
var obj = $.parseJSON(msg);
$.each(obj, function() {
ang += '<table><tr><td width="165">' + this["Athlete_Name"] + '(' + this["Athlete_Number"] + ')</td><td width="55">'+ this["Scratch_Flag"] +'</td><td width="55">'+ this["Ready_Time"] +'</td><td width="55">'+ this["Flag_Time"] +'</td><td width="55">'+ this["End_Time"] +'</td><td width="55">'+ this["Score_Time"] +'</td></tr></table>';
});
$('<p>Roster</p>').prependTo('.html(ang)');
$('#' + ID ).hide().html(ang).fadeIn('fast');
}
The Line of code called:
$('<p>Roster</p>').prependTo('.html(ang)');
Is not appending to my array of HTML that is created called 'ang' could someone point me in the right direction? many thanks
prependTo. You should be usingyourelement.prepend(ang)