View the step-by-step solution to: New Perspectives on JavaScript tutorial 4 case 1 help needed

New Perspectives on JavaScript
tutorial 4 case 1 help needed
jemenus.js

/*

New Perspectives on JavaScript, 2nd Edition
Tutorial 4
Case Problem 1
Author:
Date:

Jillian Corder
March 1, 2012

Filename:

jemenus.js

------------------------------------------------------------Function List:
setTabs()
Initializes the contents of the printer.htm Web page, locating
the tab menus and assigning event handler to the tabs.
showTab()
Shows the currently-select tab menu, bring it to the top
of the stack
------------------------------------------------------------Global Variable List:
currentTab
An object variable pointing to the currently selected tab
maxZ
A variable containing maximum z-index value among the tab lists
------------------------------------------------------------*/
var currentTab = null;
var maxZ = 1;
window.onload = setTabs;
function setTabs() {
var menuTabs = new Array();
var allElems = document.getElementsByTagName("*")
for(var i=0; i < allElems.length; i++){
if(allElems.className == 'tab'){
menuTabs.push(allElems[i]);
}
}
currentTab = menuTabs[0];
for(var i = 0; i < menuTabs.length; i++){
menuTabs[i].onclick = showTab;
function showTab() {
currentTab.style.backgroundColor = "#FFFFFF";
maxZ++;
tabList = this.getElementsByTagName("ul")[0];
tabList.style.zIndex = maxZ;
currentTab = this;
currentTab.style.backgroundColor = "rgb(221, 221, 255)";
}

Sign up to view the entire interaction

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors and customizable flashcards—available anywhere, anytime.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access or to earn money with our Marketplace.

    Browse Documents
  • 890,990,898

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
  • 890,990,898

    Flashcards

    Browse existing sets or create your own using our digital flashcard system. A simple yet effective studying tool to help you earn the grade that you want!

    Browse Flashcards