In the example, I have to click twice to see Foo content, but only once to see Bar content. The only difference is that Foo content has a internal style and Bar has inline style.
<html>
<head>
<style>
.content {
display: none;
}
</style>
<script>
function showHide(element) {
sibling = element.nextElementSibling;
if (sibling.style.display == "none")
sibling.style.display = "block"
else sibling.style.display = "none";
}
</script>
</head>
<body>
<h1 onclick="showHide(this)">Foo</h1>
<div class="content">
Foo Content
</div>
<h1 onclick="showHide(this)">Bar</h1>
<div style="display: none;">
Bar Content
</div>
</body>
</html>
You can see this code in jsfiddle here
I'd like to use internal css or external css but having the same behaviour as I get in inline css, is this possible? I guess this is a basic topic, but I don't know what concepts to use to going deeper.