Witam, napisalem taki kodzik:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <script type="text/javascript"> function togglediv(id){
var divstatus = document.getElementById(id);
if(divstatus.style.display == 'block')
divstatus.style.display = 'none';
else
divstatus.style.display = 'block';
}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Language" content="pl" /> <meta name="Robots" content="ALL" /> <meta name="keywords" content=""> <meta name="description" content="" /> <a onClick="togglediv('foo')">Naglowek 1
</a> <div id="foo" style="display:block;">Tresc naglowka 1
</div> <a onClick="togglediv('foo2')">Naglowek 2
</a> <div id="foo2" style="display:none;">Tresc naglowka 2
</div>
I teraz potrzebuje zrobic tak, aby przy otworzeniu naglowka 2 automatycznie zamykal sie naglowek 1, jak to zrobic?