-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export function addClassToTable() { | ||
// 获取所有 content 下的 table 元素 | ||
const tables = document.querySelectorAll('.content table'); | ||
|
||
// 遍历所有 table 元素 | ||
tables.forEach((table) => { | ||
// 创建一个 div 元素 | ||
const wrapper = document.createElement('div'); | ||
// 添加 class 属性 | ||
wrapper.classList.add('table-wrapper'); | ||
// 添加 text-align: cneter | ||
wrapper.style.textAlign = 'center'; | ||
// 将 table 元素包裹在 div 元素内 | ||
table.parentNode.insertBefore(wrapper, table); | ||
wrapper.appendChild(table); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters