如何在加载时将主页选项卡设为默认值?
<ul class="tab" onload="openAction(event, 'All')">
<li><a href="javascript:void(0)" class="tablinks" onclick="openAction(event, 'home')">Home</a></li>
<li><a href="javascript:void(0)" class="tablinks" onclick="openAction(event, 'generate')">Generate QR</a></li>
<li><a href="javascript:void(0)" class="tablinks" onclick="openAction(event, 'report')">Reports</a></li>
<li><a href="javascript:void(0)" class="tablinks" onclick="openAction(event, 'condemn')">Condemn Equipments</a></li>
</ul>
and upon clicking a tab
<div id="home" class="tabcontent" selected="All" background="images/bodybg.jpg">
My Home
</div>
<div id="generate" class="tabcontent" selected="All" background="images/bodybg.jpg">
Generate
</div>
<div id="report" class="tabcontent" selected="All" background="images/bodybg.jpg">
My Reports
</div>
<div id="condemn" class="tabcontent" selected="All" background="images/bodybg.jpg">
Condemn Equipments
</div>
&#13;
答案 0 :(得分:0)
<ul class="tab">
<li><a id="hometag" href="javascript:void(0)" class="tablinks" onclick="openAction(event, 'home')">Home</a></li>
<li><a href="javascript:void(0)" class="tablinks" onclick="openAction(event, 'generate')">Generate QR</a></li>
<li><a href="javascript:void(0)" class="tablinks" onclick="openAction(event, 'report')">Reports</a></li>
<li><a href="javascript:void(0)" class="tablinks" onclick="openAction(event, 'condemn')">Condemn Equipments</a></li>
</ul>
<div id="home" class="tabcontent" selected="All" background="images/bodybg.jpg">
My Home
</div>
<div id="generate" class="tabcontent" selected="All" background="images/bodybg.jpg">
Generate
</div>
<div id="report" class="tabcontent" selected="All" background="images/bodybg.jpg">
My Reports
</div>
<div id="condemn" class="tabcontent" selected="All" background="images/bodybg.jpg">
Condemn Equipments
</div>
<script>
(function() {
document.getElementById("hometag").click();
})();
</script>