Test Page: Difference between revisions

From :: ChromeRivals Wiki ::
Jump to navigation Jump to search
Ranzu (talk | contribs)
No edit summary
Ranzu (talk | contribs)
No edit summary
Line 1: Line 1:
<div id="1" class="tabcontent">
<p>Click on the buttons inside the tabbed menu:</p>
Test1
 
<div id="London" class="tabcontent">
  <h1>London</h1>
  <p>London is the capital city of England.</p>
</div>
</div>


<div id="2" class="tabcontent">
<div id="Paris" class="tabcontent">
Test2
  <h1>Paris</h1>
  <p>Paris is the capital of France.</p>
</div>
</div>


<div id="3" class="tabcontent">
<div id="Tokyo" class="tabcontent">
Test3
  <h1>Tokyo</h1>
  <p>Tokyo is the capital of Japan.</p>
</div>
</div>


<div id="4" class="tabcontent">
<div id="Oslo" class="tabcontent">
Test4
  <h1>Oslo</h1>
  <p>Oslo is the capital of Norway.</p>
</div>
</div>


Line 19: Line 25:
<button class="tablink" onclick="openCity('Tokyo', this, 'blue')">Tokyo</button>
<button class="tablink" onclick="openCity('Tokyo', this, 'blue')">Tokyo</button>
<button class="tablink" onclick="openCity('Oslo', this, 'orange')">Oslo</button>
<button class="tablink" onclick="openCity('Oslo', this, 'orange')">Oslo</button>
<script>
function openCity(cityName,elmnt,color) {
  var i, tabcontent, tablinks;
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }
  tablinks = document.getElementsByClassName("tablink");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].style.backgroundColor = "";
  }
  document.getElementById(cityName).style.display = "block";
  elmnt.style.backgroundColor = color;
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>

Revision as of 14:15, 5 September 2022

Click on the buttons inside the tabbed menu:

London

London is the capital city of England.

Paris

Paris is the capital of France.

Tokyo

Tokyo is the capital of Japan.

Oslo

Oslo is the capital of Norway.

<button class="tablink" onclick="openCity('London', this, 'red')" id="defaultOpen">London</button> <button class="tablink" onclick="openCity('Paris', this, 'green')">Paris</button> <button class="tablink" onclick="openCity('Tokyo', this, 'blue')">Tokyo</button> <button class="tablink" onclick="openCity('Oslo', this, 'orange')">Oslo</button>

<script> function openCity(cityName,elmnt,color) {

 var i, tabcontent, tablinks;
 tabcontent = document.getElementsByClassName("tabcontent");
 for (i = 0; i < tabcontent.length; i++) {
   tabcontent[i].style.display = "none";
 }
 tablinks = document.getElementsByClassName("tablink");
 for (i = 0; i < tablinks.length; i++) {
   tablinks[i].style.backgroundColor = "";
 }
 document.getElementById(cityName).style.display = "block";
 elmnt.style.backgroundColor = color;

} // Get the element with id="defaultOpen" and click on it document.getElementById("defaultOpen").click(); </script>