职教云快速复制课件所有title
本帖最后由 柒伍七 于 2022-12-11 22:43 编辑!(data/attachment/forum/202212/11/160529nsis68iljjhi7z1z.png)
```javascript
let s = document.querySelectorAll("#process_container span");
let c = "";
for (let i = 0; i < s.length; i++) {
let t = s.title;
if (t != "") {
c = c + t + "\n";
}
}
console.log(c);
copy(c);
```
> 如图,代码作用为 `快速复制课件所有title` ,用处不大(发帖作备份记录)😇 可以考虑使用 c=[]数组
push到数组里,最后join
省事一点 极品小猫 发表于 2022-12-11 23:04
可以考虑使用 c=[]数组
push到数组里,最后join
省事一点
直接innerText+replace 极品小猫 发表于 2022-12-11 23:04
可以考虑使用 c=[]数组
push到数组里,最后join
省事一点
```javascript
let s = document.querySelectorAll("#process_container span");
let arr = [];
for (let i = 0; i < s.length; i++) {
let t = s.title;
if (t != "") {
arr.push(t);
}
}
let c = arr.join("\n");
console.log(c);
copy(c);
```
> 问一下,那个是这个样子吗🧐 steven026 发表于 2022-12-11 23:14
直接innerText+replace
!(data/attachment/forum/202212/12/140135dn3hhgi3dvvd2hjj.png)
```javascript
let s = document.querySelectorAll("#process_container span");
let arr = [];
for (let i = 0; i < s.length; i++) {
let t = s.innerText;
if (t != "") {
arr.push(t);
}
}
let p = arr.join();
let re = /,/g;
let j = 1;
let c = p.replace(re,function(){j++;return j%2?"\n":arguments});
console.log(c);
copy(c);
```
> 完了,我好像是理解错了🤣 柒伍七 发表于 2022-12-12 13:30
```javascript
let s = document.querySelectorAll("#process_container span");
let arr = [];
是,其实能达到目的就行,个人觉得这种方法舒服一点 柒伍七 发表于 2022-12-12 14:01
!(data/attachment/forum/202212/12/140135dn3hhgi3dvvd2hjj.png)
```javascript
document.querySelector("#process_container").innerText.replace
具体怎么replace看具体情况 我一直都是用的数组,没想到还有这种方法哈哈哈哈哈,学到了学到了{:4_111:}
页:
[1]