I'm working on a new page and for the mobile version I'm going to make a navigation toggle in order to hide and to show the navigation.
HTML code :
<div id="toogleNavigation">
<a onclick="toggle_visibility('nav_header','nav_header_level2');">Navigation Einblenden</a>
</div>
Javascript code :
function toggle_visibility(id, id2) {
var e = document.getElementById(id);
var f = document.getElementById(id2);
if(e.style.display == 'block' ||
e.style.display == 'block' &&
f.style.display == 'block') {
e.style.display = 'none';
f.style.display = 'none';
document.getElementById('toogleNavigation').innerHTML = "Navigation 1einblenden";
} else {
e.style.display = 'block';
f.style.display = 'block';
document.getElementById('toogleNavigation').innerHTML = "Navigation 2ausblenden";
}
}
I've tried with :
document.getElementById('toogleNavigation').innerHTML = "Navigation 2ausblenden";
to change the text in text "Navigation Einblenden" when pressing on the link, but this doesn't work... Does somebody has an idea?