伙计们,我设置的div是display:none。有几个。有一个运行的脚本,当单击链接时,它会将该特定div更改为display:block。我需要的是一种使用直接超链接自动显示特定div的方法。任何想法?
谢谢,Plasmagrid
NORMAL HEADER INFORMATION ---------
<script type="text/javascript" src="http://domainlocation/Scripts/jquery.min.js"></script>
<script type="text/javascript">
function showonlyone(thechosenone) {
$('div[name|="newboxes"]').each(function(index) {
if ($(this).attr("id") == thechosenone) {
$(this).show(300);
}
else {
$(this).hide(300);
}
});
}
</script>
<BODY>
<BASEFONT SIZE="2" FACE="Arial">
<div ALIGN="center">
<TABLE CELLPADDING=3 BORDER=0 width="900px" style="font-size:14px;">
<tr>
<td>
<div align="center">
<a class="trbgshdw1" href="javascript:showonlyone('NucleusLst');" id="Nucleus">Nucleus Utilities</a>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('DisplayLst');" id="Display">Display (Monitor) Drivers</a></span>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('BiosLst');" id="Bios">Bios Utilities</a></span>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('CDImgLst');" id="CDImg">CD Imaging Utilities</a></span>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('DataCapLst');" id="DataCap">Data Capture Utility</a></span>
<br><br>
<a class="trbgshdw1" href="javascript:showonlyone('EdgePortLst');" id="EdgePort">EdgePort Drivers / Utilities</a>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('FTPLst');" id="FTP">FTP Utility</a></span>
<span style="margin-left:25px;"><a class="trbgshdw1" href="http://asonet.wayne.com/extranet/dl-Fusion.asp" id="Fusion">Fusion</a>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('HostLdrLst');" id="HostLdr">Host Loader Files</a></span>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('ModemLst');" id="Modem">Modem Drivers</a></span>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('NetworkLst');" id="Network">Network Drivers</a></span>
<br><br>
<a class="trbgshdw1" href="javascript:showonlyone('OracleLst');" id="Oracle">Oracle Files / Utilities</a>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('TankMonLst');" id="TankMon">Tank Monitoring Utilities</a></span>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('TelnetLst');" id="Telnet">Telnet Utility For ESR</a></span>
<span style="margin-left:25px;"><a class="trbgshdw1" href="javascript:showonlyone('ZipUtilLst');" id="ZipUtil">Zip / Unzip Utilities</a></span>
</div>
<br>
<!-- ** NUC **-->
<div align="left" id="NucleusLst" name="newboxes" style="display: none;"><span style="color:#FFFFFF;font-size:22px;font-weight:bold;line-height:15px;">Nucleus</span>
<table border="0" cellpadding="3" width="100%">
<TR bgcolor="#ffffff">
<td align="center" WIDTH="340px"><strong>Filename</strong></td>
<td align="center" width="*"><strong>Filesize</strong></TH>
<td align="center" WIDTH="400px"><strong>File Description</strong></Td>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">57 MB</TD>
<TD>Java 1.5.0.05 <br> It is used for reloading</TD>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">116 KB</TD>
<TD>Diagnostic Files</TD>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">161 KB</TD>
<TD>
For use with sites which may have difficulty with time change<br>
occuring on 11/01/2009.<br>
</TD>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">3.83 MB</TD>
<TD> Installation Files and Instructions</TD>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">700 KB</TD>
<TD><br>(replacement for ver4.03 CDs)</TD>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">56 KB</TD>
<TD>Matrix (as of 12/13/05)</TD>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">3 KB</TD>
<TD>Memory upgrade </TD>
</TR>
</table>
</div>
<!-- ** DISPLAY **-->
<div align="left" id="DisplayLst" name="newboxes" style="display: none;"><span style="color:#FFFFFF;font-size:22px;text-align:left;font-weight:bold:">Display (Monitors)</span>
<table border="0" cellpadding="3" width="100%">
<TR bgcolor="#ffffff">
<td align="center" WIDTH="340px"><strong>Filename</strong></td>
<td align="center" width="*"><strong>Filesize</strong></TH>
<td align="center" WIDTH="400px"><strong>File Description</strong></Td>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">2.7 MB</TD>
<TD>Drivers </TD>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">3.9 MB</TD>
<TD>Updated drivers.</TD>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">7 MB</TD>
<TD> Installation Manual<sup>Draft</sup></TD>
</TR>
</table>
</div>
<!-- ** BIOS **-->
<div align="left" id="BiosLst" name="newboxes" style="display: none;"><span style="color:#FFFFFF;font-size:22px;text-align:left;font-weight:bold:">B I O S</span>
<table border="0" cellpadding="3" width="100%">
<TR bgcolor="#ffffff">
<td align="center" WIDTH="340px"><strong>Filename</strong></td>
<td align="center" width="*"><strong>Filesize</strong></TH>
<td align="center" WIDTH="400px"><strong>File Description</strong></Td>
</TR>
<TR bgcolor="#ffffff">
<TD><a href="FILEANDLOCATION" class="font12b">FILE</a><BR><br><a href="FILEANDLOCATION" class="font12b">FILE</a></TD>
<TD align="center">1 MB<br><br>2 MB</TD>
<TD><br>To install Bios Version 1.80 Using a Diskette<BR><br>To install Bios Version 1.80 Using a<br>Memory Key,Flash Drive, Thumb Drive</TD>
</TR>
<TR bgcolor="#ffffff">
<TD align="center"><a href="FILEANDLOCATION">FILE</a></TD>
<TD align="center">168 KB</TD>
<TD>Service Memo </TD>
</TR>
<TR bgcolor="#ffffff">
<TD align="center">**********</TD>
<TD align="center">NA</TD>
<TD>INFORMAITON TO BE ADDED</TD>
</TR>
</table>
</div>
and so on for more DIVS
答案 0 :(得分:0)
使用jquery:
$('a').on('click', function(e) {
var id = $(this).attr('href');
$(id).show();
// or from your example:
showonlyone(id);
});
如果您不希望所有链接都附加事件,您需要一种方法来识别它们。
$('a[data-toggle="target"]').on('click', function(e) {
var id = $(this).attr('href');
$(id).show();
// or from your example:
showonlyone(id);
});
在上一个示例中,您将定位具有属性data-toggle="target"
的锚点:<a href="#someelementid" data-toggle="target"></a>
或者您可以定位引用ID的锚点:
$('table a[href6^="#"]').on(...)
如果锚点动态添加到文档中:
$('table').delegate('a[href6^="#"]', 'click', function(e) {...});