Javascript 如何在不使用document.writes的情况下在document.getelementById函数中编写for循环
我想在modern document.getElementById或更好的选项中更改document.write样式的代码,因为我想使用这样的多对象数组Javascript 如何在不使用document.writes的情况下在document.getelementById函数中编写for循环,javascript,optimization,Javascript,Optimization,我想在modern document.getElementById或更好的选项中更改document.write样式的代码,因为我想使用这样的多对象数组 {kapitel:['Negation','second'], name: ["<span id='buch_mathematik_symb_kap_2_8'>...</span>",'second'], a_href:['symb_negation','dsa'], buch: ['Mathematik','ddd']
{kapitel:['Negation','second'], name: ["<span id='buch_mathematik_symb_kap_2_8'>...</span>",'second'], a_href:['symb_negation','dsa'], buch: ['Mathematik','ddd']},
我不知道如何用一个document.getElementById'...innerHTML+=..来解决这个问题。。。。类型如果我为这个问题在for循环中写第二个for循环,我会得到som-NaN错误,这些错误并不酷。有没有人对此有什么建议或小例子?thx
让我们用符号和数学来表示[
//{kapitel:'Negation',name:…,a_href:'symb_Negation',buch:'Mathematik'},
{kapitel:['Negation','second'],name:[…,'second'],a_href:['symb_Negation','dsa'],buch:['Mathematik','ddd'],
{kapitel:'Konjunktion',name:…,a_href:'symb_Konjunktion',buch:'Mathematik'},
{kapitel:'Disjunktion',name:…,a_href:'symb_Disjunktion',buch:'Mathematik'},
{kapitel:'imprikation/subjectunktion',name:…,a_href:'symb_imprikation',buch:'Mathematik'},
{kapitel:'等价',名称:…,a_href:'symb_等价',buch:'Mathematik'},
{kapitel:'Nand',name:…,a_href:'symb_Nand',buch:'Mathematik'},
{kapitel:'Xor',name:…,a_href:'symb_Xor',buch:'Mathematik'},
{kapitel:'Teilbarkeit',name:…,a_href:'symb_Teilbarkeit',buch:'Mathematik'},
]
让我们从数学的角度来考虑[
{kapitel:'2.1',姓名:'Beweisführung Rechtwinkeliges Dreieck',a_href:'bf_kapitel_2_1',buch:'Mathematik'},
{kapitel:'2.3',名称:'Beweisführung direkter,indirekter and widersprüchlicher Beweis',a_href:'bf_kapitel_2_3',buch:'Mathematik',
]
让我们来学习一下数学
{kapitel:'1',name:'Bla Bla zu beginn',a_href:'Grundbegriffe_der_免疫学',buch:'Mathematik'},
{kapitel:'1.1',名称:'eaber dieses Lehrbuch,Mathematiker und mathemathik',a_href:'zf_kapitel_1_1',buch:'Mathematik'},
{kapitel:'2.1',名称:'Eine beweisende Wissenschaft',a_href:'zf_kapitel_2_1',buch:'Mathematik'},
{kapitel:'2.2',名称:'Grundbegriffe der Aussagelogik',a_href:'zf_kapitel_2_2',buch:'Mathematik'},
{kapitel:'2.3',名称:'Definition,Satz,Beweis',a_href:'zf_kapitel_2_3',buch:'Mathematik'},
]
文件。写“Inhaltsverzeichins”;
文件。书写;
文件。书写;
对于NR_i=0;NR_ifunction content(param,i){
return `<li>
<table>
<tr>
<td style="width:30px">
${param[i].name}
</td>
<td>
<a href="#
${param[i].a_href}
" >
${param[i].kapitel }.
</a>
</td>
</tr>
</table>
</li> `;
}
function createContent(obj){
for (let i = 0; i < obj.length; i++) {
document.write(content(obj,i));
}
}
document.write('<button class="buttn" onclick="myFunction(\'index\')" style="color:red;">Inhaltsverzeichnis</button><div id="index" style="display:none-;">');
document.write('<ul style="list-style: none;">');
document.write('<table><tr><td valign="top">');
<!-- Inhaltsverzeichnis buch_mathematik.js - Kapitel -->
createContent(inhaltsverzeichnis_mathematik);//call function
document.write('</td><td valign="top">');
<!-- Inhaltsverzeichnis buch_mathematik.js - Beweise -->
createContent(inhaltsverzeichnis_Beweisfuehrung_mathematik);//call function
document.write('</td><td valign="top">');
<!-- Inhaltsverzeichnis buch_mathematik.js - Symbole -->
createContent(inhaltsverzeichnis_symbole_mathematik);//call function
document.write('</td></tr></table>');
document.write('</ul></div>');