跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
特殊页面
搜索
搜索
外观
创建账号
登录
个人工具
创建账号
登录
查看“︁模板:Collapse/common.js”︁的源代码
模板
讨论
简体中文
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
←
模板:Collapse/common.js
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
document.addEventListener("DOMContentLoaded", () => { const headers = document.querySelectorAll('.scr-collapse-header'); headers.forEach(header => { const content = header.nextElementSibling; const symbol = header.querySelector('.scr-collapse-symbol'); const textOpen = header.getAttribute('data-text-open') || '+ 展开'; const textClose = header.getAttribute('data-text-close') || '- 收起'; const defaultState = header.getAttribute('data-default') || 'closed'; if (defaultState === 'open') { content.style.maxHeight = content.scrollHeight + "px"; symbol.textContent = textClose; } else { content.style.maxHeight = "0"; symbol.textContent = textOpen; } header.addEventListener('click', () => { if (content.style.maxHeight && content.style.maxHeight !== "0px") { content.style.maxHeight = "0"; symbol.textContent = textOpen; } else { content.style.maxHeight = content.scrollHeight + "px"; symbol.textContent = textClose; } }); }); });
返回
模板:Collapse/common.js
。
搜索
搜索
查看“︁模板:Collapse/common.js”︁的源代码
添加话题