Was stimmt an dem folgenden Code nicht?
JavaScript
<script type="text/javascript">function change(id) { if (document.getElementById(id).style.display != 'none') { document.getElementById(id).style.display = 'block'; } else { document.getElementById(id).style.display = 'none'; }return true;}
</script>
<a onClick="change('test')" href="#"> Test-DIV öffnen! </a> <br /><div id="test" style="display:none;"> Test Test Test </div>
Google Chrome macht die Absätze immer weg. Also hier ohne Syntaxhighlighting mit Absätzen:
<script type="text/javascript">
function change(id) {
if (document.getElementById(id).style.display != 'none') {
document.getElementById(id).style.display = 'block';
}
else {
document.getElementById(id).style.display = 'none';
}
return true;
}
</script>
<a onClick="change('test')" href="#"> Test-DIV öffnen! </a> <br />
<div id="test" style="display:none;"> Test Test Test </div>