I’ve a html string value from .net and stored in view data
in jquery i’m reading that like this
var htmlTranTable = '@ViewData["tblView"]';
$('#divTransactions').append(htmlTranTable);
And this is the sample html string that i received from .net viewdata
var htmlTranTable = `<table class='table table-bordered row-border table-responsive' id='htmlTableTransactions'>
<thead>
<tr>
<th class='text-nowrap'>Transaction No</th >
<th class='text-nowrap'>Status</th >
</tr>
</thead>
<tbody>
<tr>
<td>510002500007484</td>
<td>Completed With Migration Successful</td>
</tr>
<tr>
<td>510002500007475</td>
<td>Completed With Migration Successful</td>
</tr>
</tbody>
</table>`
when I try to append the value in a div like this
HTML/Div
<div class="table-responsive" id="divTransactions" style="overflow:hidden"></div>
JS
$('#divTransactions').append(htmlTranTable);
// or
document.getElementById("divTransactions").innerHTML += htmlTranTable;
when I run this I’m getting output like this image
as plain string inside the div .. please let me if you’ve any solution thanks
2
Answers
try with one of these:
first create the div element inside your div, and then do the innerhtml like this. hopes it helps this example
You can use the below code
This is perfect for working with your code.