Advertisement
Svetlana_Ovsjanikova

html_JS

Sep 26th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. function openCity(cityName, elmnt, color) {
  2. // Hide all elements with class="tabcontent" by default */
  3. var i, tabcontent, tablinks;
  4. tabcontent = document.getElementsByClassName("tabcontent");
  5. for (i = 0; i < tabcontent.length; i++) {
  6. tabcontent[i].style.display = "none";
  7. }
  8.  
  9. // Remove the background color of all tablinks/buttons
  10. tablinks = document.getElementsByClassName("tablink");
  11. for (i = 0; i < tablinks.length; i++) {
  12. tablinks[i].style.backgroundColor = "";
  13. }
  14.  
  15. // Show the specific tab content
  16. document.getElementById(cityName).style.display = "block";
  17.  
  18. // Add the specific color to the button used to open the tab content
  19. elmnt.style.backgroundColor = color;
  20. }
  21.  
  22. // Get the element with id="defaultOpen" and click on it
  23. document.getElementById("defaultOpen").click();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement