Can you please take a look at this code and let me know why I am not able add the variable into the table?
var variable = "app ha";
var table = '<table class="table table-striped table-bordered"><tr><td>Energy Target</td><td><span class="'+ variable +'"></span></td></tr><tr><td>Run of River Priorities:</td><td><span class="'+ variable +'"></span></td></tr><tr><td>Species:</td><td><span class="'+ variable +'"></span></td></tr><tr><td>Disturbance:</td><td><span class="'+ variable +'"></span></td></tr><tr><td>Slider:</td><td><span class="'+ variable +'"></span></td></tr></table>';
$("body").append(table);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
Your variable is succefully added as class attribute, if you want to show it inside tds add it also inside column :
var table = '<table ....
<tr>
<td>Energy Target</td>
<td><span class="'+ variable +'">'+ variable +'</span></td>
</tr>
.....</table>';
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With