Java Reference
In-Depth Information
showDescription(num);
activeTab = target;
}
break;
}
}
function showDescription(num) {
var descContainer = document.getElementById("descContainer");
var text = "Description for Tab " + num;
descContainer.innerHTML = text;
}
evt.addListener(document, "mouseover", handleEvent);
evt.addListener(document, "mouseout", handleEvent);
evt.addListener(document, "click", handleEvent);
</script>
</body>
</html>
Save this as ch10 _ question3.html .
This solution starts with a new global variable called activeTab . Its purpose is to contain a
reference to the tab element that was last clicked, and you initialize it as null .
When you click a tab element, you first need to deactivate the currently active tab:
if (activeTab) {
activeTab.className = "tabStrip-tab";
}
To do that, you first check if you have an active tab, and if so, you set its className property back
to the original tabStrip‐tab . Then after you activate the new tab, you assign it to the activeTab
variable:
activeTab = target;
Simple, but effective.
Chapter 11
exercise 1 Question
Using the code from the temperature converter example you saw in Chapter 2, create a user interface
for it and connect it to the existing code so that the user can enter a value in degrees Fahrenheit and
convert it to centigrade.
Search WWH ::




Custom Search