Hi,
I'm new to Javascript, so please bear with me if my question seems silly. I found code on a website part of which is shown below:
What I find hard to understand is how can tab0 be passed to getElementById('tab'). I thought the id had to be "tab" and not tab0, tab1, etc. Further, what is the purpose of class="select curvyRedraw", what does it actually do. I would be very grateful for all help.
I'm new to Javascript, so please bear with me if my question seems silly. I found code on a website part of which is shown below:
Code:
<script type="text/javascript">
var selectedTab = 0;
function tabclick(n) {
if (n === selectedTab) return; // nothing to do.
curvyCorners.setWinResize(false); // for IE, block spurious window resize events
var li = document.getElementById('tab' + selectedTab);
curvyCorners.adjust(li, 'className', ''); // Remove the 'select' style
li = document.getElementById('page' + selectedTab);
li.style.display = 'none'; // hide the currently selected sub-page
li = document.getElementById('page' + n);
li.style.display = 'block'; // show the new sub-page
li = document.getElementById('tab' + n); // get the new (clicked) tab
curvyCorners.adjust(li, 'className', 'select'); // and update its style
curvyCorners.redraw(); // Redraw all elements with className curvyRedraw
selectedTab = n; // store for future reference
curvyCorners.setWinResize(true); // OK, allow genuine resize events now
}
curvyCorners.addEvent(window, 'resize', new Function('curvyCorners.handleWinResize();'));
</script>
<body>
.........
<div id="tabrow">
<ul>
<li id="tab0" onclick="tabclick(0);" class="select curvyRedraw">Intro</li>
<li id="tab1" onclick="tabclick(1);" class="curvyRedraw">RepeatX</li> ............
</body>
What I find hard to understand is how can tab0 be passed to getElementById('tab'). I thought the id had to be "tab" and not tab0, tab1, etc. Further, what is the purpose of class="select curvyRedraw", what does it actually do. I would be very grateful for all help.