Hy
Habe folgendes problem, möchte einen Teil in js erstellen lassen (denke wäre sinvoll) Nur kein plan wie man ein erstelltest element weitere element darunter hinzufügt. div Id=" valueStats" steht im html code bereit.
Hier der Html code:
Code
<div id="valueStats">
<div class="min-row" id="mainBlock">
<div class="min-col-1 start">
<ul>
<li>MAX TP</li>
<li>ANG</li>
<li>K.VERT</li>
<li>M.VERT</li>
</ul>
</div>
<div class="min-col-2">
<ul>
<li><span>0</span> ( <span id="Hp"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="Atk"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="P_Def"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="M_Def"></span> + <span>0</span> )</li>
</ul>
</div>
</div>
<div class="min-row">
<div class="min-col-1 start">
<ul>
<li>ANG Geschw.</li>
<li>Krit</li>
<li>Krit. Schaden</li>
<li>Durchdringung</li>
<li>Lebensraub</li>
<li>MP Erholung/Angriff</li>
<li>MP Erholung/Schaden</li>
<li>MP Erholung/Sek</li>
<li>PRÄZ</li>
</ul>
</div>
<div class="min-col-1">
<ul>
<li><span>0</span> ( <span id="Atk_Speed"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="Crit"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="Crit_Dmg"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="Penetration"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="Mp_Recovery_Atk"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="Acc"></span> + <span>0</span> )</li>
</ul>
</div>
<div class="min-col-1">
<ul>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
</ul>
</div>
</div>
<div class="min-row">
<div class="min-col-1 start">
<ul>
<li>K. Block</li>
<li>K. Block VERT.</li>
<li>K. Ausw.</li>
<li>K. Stärkung</li>
<li>K. Krit Resistance</li>
</ul>
</div>
<div class="min-col-1">
<ul>
<li><span>0</span> ( <span id="P_Block"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="P_Block_Def"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="P_Dodge"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="P_Tough"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
</ul>
</div>
<div class="min-col-1">
<ul>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
</ul>
</div>
</div>
<div class="min-row">
<div class="min-col-1 start">
<ul>
<li>M. Block</li>
<li>M. Block VERT.</li>
<li>M. Ausw.</li>
<li>M. Stärkung</li>
<li>M. Krit Resistance</li>
</ul>
</div>
<div class="min-col-1">
<ul>
<li><span>0</span> ( <span id="M_Block"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="M_Block_Def"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="M_Dodge"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id="M_Tough"></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
</ul>
</div>
<div class="min-col-1">
<ul>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
</ul>
</div>
</div>
<div class="min-row">
<div class="min-col-1 start">
<ul>
<li>Block</li>
<li>VERT</li>
<li>Ausw.</li>
<li>Krit Resistance</li>
<li>CC Resistenz</li>
<li>Schwächung PRÄZ</li>
</ul>
</div>
<div class="min-col-1">
<ul>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
<li><span id="Cc_Resist"></span> ( <span id=""></span> + <span>0</span> )</li>
<li><span>0</span> ( <span id=""></span> + <span>0</span> )</li>
</ul>
</div>
<div class="min-col-1">
<ul>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
<li><span>0</span>%</li>
</ul>
</div>
</div>
</div>
Alles anzeigen
Hier mein js:
Code
const categoryBox = {
mainBox: { hp: 'MAX TP', atk: 'Ang', p_Def:'K. Def', m_Def: 'M. Def'},
offensiveBox: { crit: 'Krit', crit_Dmg: 'Krit Schaden', penetration: 'Durchdringung', acc: 'Präz'},
defensiveBox: { p_Dodge: 'K. Ausweichen', m_Dodge: 'M. Ausweichen', p_Block: 'K. Block', m_Block: 'M. Block', p_Block_Def: 'K. Block Vert.', m_Block_Def: 'M. Block Vert.', p_Tough: 'K. Stärkung', m_Tough: 'M. Stärkung', p_Crit_Resist: 'K. Krit WDST', m_Crit_Resist: 'M. Krit WDST'},
subBlockBox: { cc_Resist: 'CC-WDST', cc_Acc: 'CC-Präz', lifesteal: 'Lebensraub', atk_Speed: 'Ang Geschw.', mp_Recover_Atk: 'MP Erholung/Ang', mp_Recover_Dmg: 'MP Erholung/Schaden', mp_Recover_Sec: 'MP Erholung/Sekunde'},
};
window.onload = function () {
let container = document.getElementById('valueStats');
htmlFragment = document.createDocumentFragment();
console.log(container);
for(let property in categoryBox){
createCategory(property);
}
console.log(htmlFragment);
}
// create category & add id, class
function createCategory(elem) {
let newDiv = document.createElement('div');
if(categoryBox.hasOwnProperty(elem)) {
newDiv.id = elem;
newDiv.classList.add('min-row');
}
console.log(categoryBox[elem]);
htmlFragment.appendChild(newDiv);
console.log(newDiv);
}
Alles anzeigen
Geht das so in die richtige richtung oder lauf ich da gegen was an?
(Internet spuckt nix aus, ausßer createElement(), creatDocumentFragment(), )
Bitte um tipps.
Mfg.
PS. Frohe Ostern!