我正在尝试设置一个带有手风琴的页面,我可以在其中更改默认打开的行,每季度一次。这是在 SharePoint 网站中完成的,因此我能做的事情有些有限。
该代码使用 SharePoint Web 部件标题来提取用于显示其内容的 HTML 编码。这段代码不是我写的,而是从Mark Rackley的"Hillbilly tabs"网站上复制/修改的。
这是Javascript:
<script type="text/javascript">
jQuery(document).ready(function($) {
//Put the WebPart Title for all the Web Parts you wish
//to put into the jQuery UI Accordion into the array below.
Hillbillyaccordion(["FY18Q4","FY19Q1","FY19Q2"]);
});
function Hillbillyaccordion(webPartTitles)
{
for(index in webPartTitles)
{
var title = webPartTitles[index];
$("#accordion").append('<h3>'+title+'</h3>');
$("span:contains('"+title+"')").each(function(){
if ($(this).text() == title){
var webPart = $(this).hide().closest("span").closest("[id^='MSOZoneCell_WebPart']");
if ($(webPart).contents().html() != undefined)
{
webPart = $(webPart).contents();
}
$("#accordion").append(webPart);
}
});
}
$("#accordion").accordion({ heightStyle: "content" });
}
</script>
<div id="accordion"></div>
该 HTML:
<table class="ms-rteTable-0" cellspacing="0" style="width: 65%;">
<tbody>
<tr>
<td class="ms-rteTable-0" style="width: 100%;">
<div class="ms-rtestate-read ms-rte-wpbox" contenteditable="false">
<div class="ms-rtestate-notify ms-rtestate-read f0bd8512-73d2-4d90-822d-23db740f5665" id="div_f0bd8512-73d2-4d90-822d-23db740f5665" unselectable="on">
</div>
<div id="vid_f0bd8512-73d2-4d90-822d-23db740f5665" unselectable="on" style="display: none;">
</div>
</div>
<div class="ms-rtestate-read ms-rte-wpbox" contenteditable="false">
<div class="ms-rtestate-notify ms-rtestate-read 5fc7f31f-65af-432a-8b21-10c760226ccf" id="div_5fc7f31f-65af-432a-8b21-10c760226ccf" unselectable="on">
</div>
<div id="vid_5fc7f31f-65af-432a-8b21-10c760226ccf" unselectable="on" style="display: none;">
</div>
</div>
<div class="ms-rtestate-read ms-rte-wpbox" contenteditable="false">
<div class="ms-rtestate-notify ms-rtestate-read 5233fd78-4eff-410c-a3df-eedf46f80376" id="div_5233fd78-4eff-410c-a3df-eedf46f80376" unselectable="on">
</div>
<div id="vid_5233fd78-4eff-410c-a3df-eedf46f80376" unselectable="on" style="display: none;">
</div>
</div>
<p>
<br/> </p>
<div class="ms-rtestate-read ms-rte-wpbox" contenteditable="false">
<div class="ms-rtestate-notify ms-rtestate-read 2783a954-2339-4353-b420-63a2dd92b0e5" id="div_2783a954-2339-4353-b420-63a2dd92b0e5" unselectable="on">
</div>
<div id="vid_2783a954-2339-4353-b420-63a2dd92b0e5" unselectable="on" style="display: none;">
</div>
</div> </td>
</tr>
</tbody>
</table>
因此,在这种情况下,我希望默认情况下打开FY19Q1行。现在,FY18Q4是打开的(当我点击其他地方时关闭(。
希望得到任何提示或帮助。谢谢。
使用 jQuery accordian 的 active
选项。积极
$("#accordion").accordion({ heightStyle: "content", active: 1/*The 2nd accordian*/ });