sethwb
07-14-2009, 10:33 PM
This code is for tabbed content (click a tab and it changes what is displaying beneath the tabs).
My javascript:
var ztabs = new Array();
$(document).ready(function() {
$("a[name^='tab-']").each(function() {
$(this).click(function() {
if( $("#" + this.name).is(':hidden') ) {
for(mi=1;mi<4;mi++) {
ztabs[mi] = document.getElementById('tab-'+mi);
if( ztabs[mi].style.display == "") {
ztabs[mi].style.display = "none";
}
}
$("#" + this.name).show();
}
return false;
});
});
});
my html:
<table class="InfoTable">
<tbody>
<tr>
<td colspan="4" class="InfoTableItem">
product1 name
</td>
</tr>
<tr>
<td class="InfoTableTab">
<a href="#" name="tab-1">Description</a>
</td>
<td class="InfoTableTab" name="tab-2">
<a href="#" name="tab-2">Application</a>
</td>
<td class="InfoTableTab" name="tab-3">
<a href="#" name="tab-3">Datasheet</a>
</td>
<td class="InfoTableSpace">
</td>
</tr>
<tr>
<td colspan="4" class="InfoTableTabContent">
<div id="tab-1">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat...
</div>
<div id="tab-2" style="display: none;">
2
</div>
<div id="tab-3" style="display: none;">
3
</div>
</td>
</tr>
</tbody>
</table>
Any ideas on how to crunch that nested if statement inside a loop inside an if statement?
My javascript:
var ztabs = new Array();
$(document).ready(function() {
$("a[name^='tab-']").each(function() {
$(this).click(function() {
if( $("#" + this.name).is(':hidden') ) {
for(mi=1;mi<4;mi++) {
ztabs[mi] = document.getElementById('tab-'+mi);
if( ztabs[mi].style.display == "") {
ztabs[mi].style.display = "none";
}
}
$("#" + this.name).show();
}
return false;
});
});
});
my html:
<table class="InfoTable">
<tbody>
<tr>
<td colspan="4" class="InfoTableItem">
product1 name
</td>
</tr>
<tr>
<td class="InfoTableTab">
<a href="#" name="tab-1">Description</a>
</td>
<td class="InfoTableTab" name="tab-2">
<a href="#" name="tab-2">Application</a>
</td>
<td class="InfoTableTab" name="tab-3">
<a href="#" name="tab-3">Datasheet</a>
</td>
<td class="InfoTableSpace">
</td>
</tr>
<tr>
<td colspan="4" class="InfoTableTabContent">
<div id="tab-1">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat...
</div>
<div id="tab-2" style="display: none;">
2
</div>
<div id="tab-3" style="display: none;">
3
</div>
</td>
</tr>
</tbody>
</table>
Any ideas on how to crunch that nested if statement inside a loop inside an if statement?