我想,我目前的代码不是: 1.如果条件1存在,则显示html的第1部分 2.如果条件2存在,则显示html的第2部分 3.否则隐藏第2部分并显示第1部分 4.如果条件1,则将TD id“ATA”的背景颜色更改为:#d6e8ff 5.如果条件2,则将TD id“QGA”的背景颜色更改为:#d6e8ff 6.我需要保留“(”.ms-sitemapdirectional“)。text()=='ARMARTApplication Approval Transition by Phase')”因为这是我在sharepoint中抓取当前页面的方式。
<head>
<script src="/sites/ADMRun/SiteCollectionDocuments/jquery.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
//alert($(".ms-sitemapdirectional").text());
var showItem = function (.ms-sitemapdirectional, div) {
if($(".ms-sitemapdirectional").text()=='ARMARTApplication Approval Transition by Phase'){
$("#DOCMGT").attr("href","http://www.yahoo.com"); //Application Approval Link
$("#DOCMGTP").attr("href","http://www.yahoo.com"); //Application Approval Link
$("#QGATE").attr("href","http://www.yahoo.com"); //Quality Gate List Link
$("#ATA").addClass('color');
$("#QGA").removeClass('color'); //No background color
$("#section1").removeClass('hide');
$("#section2").addClass('hide'); //Hide section
}
else ($(".ms-sitemapdirectional").text()=='ARMARTQuality Gate Approvals by Phase'){
$("#DOCMGT").attr("href","http://www.yahoo.com"); //Application Approval Link
$("#DOCMGTP").attr("href","http://www.yahoo.com"); //Application Approval Link
$("#QGATE").attr("href","http://www.yahoo.com"); //Quality Gate List Link
$("#QGA").addClass('color');
$("#ATA").removeClass('color'); //No background color
$("#section2").removeClass('hide');
$("#section1").addClass('hide'); //Hide section
}
};
// register a listener to the links
$('#changer a').on('click', function () {
var itemId = $(this).attr('id');
var .ms-sitemapdirectional = $(this).text();
showItem(linkText);
});
});
</script>
</head>
<!--I don't want to have additional urls above the table-->
<div id="changer">
<a href="#" class="ms-sitemapdirectional">INFOKEEP</a> | <a href="#" class="ms-sitemapdirectional">INFONOTKEPT</a> | <a href="#" class="ms-sitemapdirectional">INFOSOMETHINGELSE</a>
</div>
<TABLE style="WIDTH: 100%" border=1 summary="Document Approvals">
<TBODY>
<TR>
<!--This section should control the href attributes from the jquery-->
<TD><A id=DOCMGTP><IMG border=0 src="http://placekitten.com/g/100/100"></A></TD>
<TD id=ATA><FONT size=2><STRONG><A id=DOCMGT>Application Transition Approvals</A></STRONG></FONT></TD>
<TD id=QGA class="color"><FONT size=2><STRONG><A id=QGATE>Quality Gate Approvals</A></STRONG></FONT></TD></TR></TBODY></TABLE>
<!--Section 1-->
<div id="section1" class="hide">
<BR><STRONG>Instructions:</STRONG> Use this Document Approval tool to track Application Transition Approvals by Phase.<BR>
<STRONG><EM>Documents are to be located</EM></STRONG>: /<B><I><SPAN style="COLOR: #00b050">COE Name</SPAN></I></B>/Shared Documents/Project Management/Quality Gate/
<B><I><SPAN style="COLOR: #00b050">Application Name/Phase Name (Unique folder for each application and phase per application)</SPAN> </I></B>
</div>
<!--Section 2-->
<div id="#section2" class="hide">
<STRONG>Instructions:</STRONG> Use this Document Approval tool to track Quality Gate Approvals by Phase.<BR>
<STRONG><EM>Documents are to be located</EM></STRONG>: /<B><I><SPAN style="COLOR: #00b050">COE Name</SPAN></I></B>/Shared Documents/Project Management/Quality Gate/
</div>