Line 3: | Line 3: | ||
<script> | <script> | ||
− | function openCity( | + | function openCity(cityName) { |
− | + | var i; | |
− | + | var x = document.getElementsByClassName("city"); | |
− | + | for (i = 0; i < x.length; i++) { | |
− | + | x[i].style.display = "none"; | |
− | + | } | |
− | + | document.getElementById(cityName).style.display = "block"; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
</script> | </script> | ||
− | |||
<head> | <head> | ||
Line 34: | Line 28: | ||
<br><br><br><br><br><br> | <br><br><br><br><br><br> | ||
− | |||
− | + | <div class="w3-bar w3-black"> | |
− | + | <button class="w3-bar-item w3-button" onclick="openCity('London')">London</button> | |
− | + | <button class="w3-bar-item w3-button" onclick="openCity('Paris')">Paris</button> | |
− | + | <button class="w3-bar-item w3-button" onclick="openCity('Tokyo')">Tokyo</button> | |
− | + | </div> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <div id="London" class="city"> | |
− | + | <h2>Experiment</h2> | |
− | + | <p></p> | |
− | + | ||
</div> | </div> | ||
+ | <div id="Paris" class="city" style="display:none"> | ||
+ | <h2>Notebook</h2> | ||
+ | <p>Paris is the capital of France.</p> | ||
+ | </div> | ||
+ | <div id="Tokyo" class="city" style="display:none"> | ||
+ | <h2>Attribution</h2> | ||
+ | <p>Tokyo is the capital of Japan.</p> | ||
+ | </div> | ||
</body> | </body> | ||
</html> | </html> |
Revision as of 12:24, 16 October 2018