我已经查看了似乎有一百万个示例,说明如何获取用户单击以更改类的链接,同时确保同级链接采用其原始类。我对 jQuery 很陌生,所以当我尝试这些不同的示例时,我承认我迷失了。这是我的CSS:
/*active link */
.current {
color: #f48239;
text-decoration: none;
}
/* inactive link*/
.link {
color: black;
text-decoration: none;
}
只显示与被点击的链接对应的 div 内容的 jQuery 函数:
$(document).ready(function(){
$('a').click(function () {
var divname= this.name;
$("#"+divname).show("fast").siblings().hide("fast");
});
});
现在是 HTML:
<div id="left">
<UL><h2>DBACO Projects</h2></UL>
<div id="headerspace">
</div>
<UL ID="links"><LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="QualcommInfo">QUALCOMM BUILDING M PROJECTS</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="StFrancisInfo">ST FRANCIS OF ASSISI CATHOLIC COMMUNITY-PHASE 1</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="YumaInfo">YUMA PIVOT POINT HOTEL AND CONFERENCE CENTER</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="RealtyInfo">REALTY INCOME CORPORATE HEADQUARTERS</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="CenterCityInfo">CENTER CITY MARRIOTT</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="PalmInfo">PALM MOUNTAIN RESORT</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="TrailsInfo">THE TRAILS AT PALM SPRINGS</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="OtayInfo">OTAY LOGISTICS CENTER</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="CabrilloInfo">CABRILLO MEDICAL OFFICE BUILDING</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="NorthgateInfo">NORTHGATE COMMUNITY CHURCH</A></h6></LI><BR>
<LI><h6 style="display: inline;"><A class="link" HREF="#" NAME="LomaInfo">LOMA ALTA VILLAGE MOB</A></h6></LI></UL>
</div>
任何关于如何点击链接以获取“当前”类同时确保所有其他链接保持在“链接”类中的任何想法都将不胜感激。