여기에서 예를 들어 http://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_accordion 처음에는 아코디언을 열어서 w3-show 스타일을 클래스에 추가했지만 왜 작동하지 않는지 알고 싶습니다.내 아코디언이 열리지 않는 이유
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body>
<div class="w3-container">
<h2>Accordions</h2>
<p>An accordion is used to show (and hide) content that is broken into sections:</p>
<div class="w3-accordion w3-light-grey">
<button onclick="myFunction('Demo1')" class="w3-btn-block w3-left-align w3-show">Open Section 1</button>
<div id="Demo1" class="w3-accordion-content w3-container">
<h4>Section 1</h4>
<p>Some text..</p>
</div>
<button onclick="myFunction('Demo2')" class="w3-btn-block w3-left-align w3-show">Open Section 2</button>
<div id="Demo2" class="w3-accordion-content w3-container">
<h4>Section 2</h4>
<p>Some other text..</p>
</div>
</div>
</div>
<script>
function myFunction(id) {
var x = document.getElementById(id);
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");
}
}
</script>
</body>
</html>