MediaWiki:Common.js:修订间差异
外观
无编辑摘要 标签:移动版编辑 移动版网页编辑 高级移动版编辑 |
无编辑摘要 标签:移动版编辑 移动版网页编辑 高级移动版编辑 |
||
| 第1行: | 第1行: | ||
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | ||
( | |||
document.addEventListener('DOMContentLoaded', () => { | |||
document.querySelectorAll('.scr-collapse-header').forEach(header => { | |||
const content = header.nextElementSibling; | const content = header.nextElementSibling; | ||
const | const textOpen = header.dataset.open; | ||
const | const textClose = header.dataset.close; | ||
header.addEventListener('click', () => { | |||
const expanded = content.style.maxHeight && content.style.maxHeight !== '0px'; | |||
if (expanded) { | |||
content.style.maxHeight = '0'; | |||
header.textContent = textOpen; | |||
} else { | |||
content.style.maxHeight = content.scrollHeight + 'px'; | |||
header.textContent = textClose; | |||
} | |||
}); | |||
}); | }); | ||
} | }); | ||
2026年1月7日 (三) 01:07的版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.scr-collapse-header').forEach(header => {
const content = header.nextElementSibling;
const textOpen = header.dataset.open;
const textClose = header.dataset.close;
header.addEventListener('click', () => {
const expanded = content.style.maxHeight && content.style.maxHeight !== '0px';
if (expanded) {
content.style.maxHeight = '0';
header.textContent = textOpen;
} else {
content.style.maxHeight = content.scrollHeight + 'px';
header.textContent = textClose;
}
});
});
});