拆分 JavaScript 文件
This commit is contained in:
19
assets/js/nav-functions.js
Normal file
19
assets/js/nav-functions.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// 查找字符 tChar 在 str 中第 num 次出现的位置
|
||||
|
||||
function findChar(str, tChar, num) {
|
||||
var charPos = str.indexOf(tChar);
|
||||
num = num - 1;
|
||||
if (num > 0) {
|
||||
for (var i = 0; i < num; i++) {
|
||||
charPos = str.indexOf(tChar, charPos + 1);
|
||||
}
|
||||
}
|
||||
return charPos;
|
||||
}
|
||||
|
||||
// 返回顶部
|
||||
|
||||
function toTop() {
|
||||
document.body.scrollTop = 0;
|
||||
document.documentElement.scrollTop = 0;
|
||||
}
|
Reference in New Issue
Block a user