basti1012
Erfahrenes Mitglied
so sollte es jetzt gehen
Link zur Lösung

Link zur Lösung

Zuletzt bearbeitet:
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
<h2 class="boxTitle anaus"><a href="#"><span class="text"></span></a> Tauschpartner <a href="index.php?info=tauschpartner">[?]</a></h2>
Da HTML prozedural abgearbeitet wird ist es eigentlich ungünstig JS-Code im header zu haben weil da das DOM noch nicht fertig ist. Deshalb muss man immer auch ein Event, wieIch habe es zumindest so gelernt, dass alle script-Teile in den Header-Teil kommen.
window.onload
oder document.addEventListener("DOMContentLoaded", …)
abfragen. Sonst wird der Code ausgeführt obwohl entsprechendes DOM noch nicht verfügbar ist.Fa
kann schon richtig sein. je nachdem ob @Dragosius Fontawesome 4 oder 5/6 verwednet.Ich persönlich finde noch das es ganz schön merkwürdig ist in Code deutsche variablen zu lesen
ich hab mir inzwischen angewöhnt IDs nur noch für JS zu verwenden und Klassen nur für CSS
$('table[name="name"])
<script>
document.addEventListener("DOMContentLoaded", function(event) {
h=0;
g=0;
var neuer_wert;
if(localStorage.getItem('boxen')){
start=JSON.parse(localStorage.getItem('boxen'));
}else{
start=Array('true','true','true','true','true','true','true');
}
const elestart=document.querySelectorAll('.boxRight .boxContentRight');
fa=document.querySelectorAll('.anaus .textRight');
elestart.forEach(function(f,index){
if(start[g]=='true'){
icon='minus';
} else {
f.classList.add('aus');
icon='plus';
}
fa[index].innerHTML='<div class="icon icon24 fa fa-'+icon+'-square nachrichten-iconfarbe"></div>';
g++;
});
ele=document.querySelectorAll('.boxRight');
ele.forEach(function(f,index){
but=f.querySelectorAll('.anaus');
but[0].addEventListener('click',function(){
fa=f.querySelectorAll('.textRight');
g=f.querySelectorAll('.boxContentRight');
if(g[0].classList.contains("aus")){
g[0].classList.remove('aus');
neuer_wert='true';
icon='minus';
}else{
g[0].classList.add('aus');
neuer_wert='false';
icon='plus';
}
fa[0].innerHTML='<div class="icon icon24 fa fa-'+icon+'-square nachrichten-iconfarbe"></div>';
start.splice(index, 1, neuer_wert)
localStorage.setItem('boxen',JSON.stringify(start));
});
h++;
})
});
</script>
.aus{
display:none;
}
<!-- rechte Box - Dailies - Anfang -->
<section class="box boxRight">
<h2 class="boxTitle anaus"><span class="textRight"></span> Dailies <a href="index.php?info=dailies">[?]</a></h2>
<div class="boxContent boxContentRight">
<div class="sidebarItemTitle">
[Inhalt]
</div>
</div>
</section>
<!-- rechte Box - Dailies - Ende -->
<!-- rechte Box - Shoutbox - Anfang -->
<section class="box boxRight">
<h2 class="boxTitle anaus"><span class="textRight"></span> Shoutbox <span class="icon icon16 fa-refresh refresh-shoutbox"></span></h2>
<div class="boxContent boxContentRight">
<div class="sidebarItemTitle">
[Inhalt]
</div>
</div>
</section>
<!-- rechte Box - Shoutbox - Ende -->