以上代码使用JSON
输出生成HTML表格。JQuery加载后未显示网页内容
但是,我的问题是,此JQuery
运行后,其他页面内容不显示。
<script>
$(document).ready(function() {
var html = '<table class="table table-striped">';
html += '<tr>';
var flag = 0;
var data2 = <?php echo $data; ?>;
$.each(data2[0], function(index, value){
html += '<th>'+index+'</th>';
});
html += '</tr>';
$.each(data2, function(index, value){
html += '<tr>';
$.each(value, function(index2, value2){
html += '<td>'+value2+'</td>';
});
html += '<tr>';
});
html += '</table>';
$('body').html(html);
console.log(html);
});
</script>
当页面加载时,内容应该消失,它应该只显示特定的表。
那是因为你基本上是更换你的身体的所有内容,这表,看你的代码$('body')。html(html)。 – imprezzeb
你提到过,“内容应该消失,它应该只显示特定的表格”。根据你所提到的,你的代码完全一样。它用你在这个脚本中建立的表格替换了主体中的所有内容(即,**页面中的所有**)!现在最新的问题是什么? –
@PrashanthBenny好吧然后我需要做什么,我如何生成与其他表格内容 – Rooter