gpt4 book ai didi

css - 复制一个元素?

转载 作者:太空宇宙 更新时间:2023-11-03 19:52:34 59 4
gpt4 key购买 nike

我正在尝试复制页面中的元素。我不知 Prop 体怎么做,是否可以使用 CSS 或我需要使用脚本?

我想象的是这样的:

  #yan:before { 
content: Get The Value Of(AN.element.inPage) !important;
font-size: 200% !important;
}

例如: 假设我想获取主题的标题。

  #yan:before { 
content: Get The Value Of(h1.subject) !important;
font-size: 200% !important;
}

然后主题标题将在页面中出现 2 次。可能吗?

现在这是我的正确代码...

// ==UserScript==
// @name DUPLICATING - CLONE elements
// @namespace http://userscripts.org/scripts/show/109262
// @description EXPLAIN ME PLEASE
// @include http*://*answers.yahoo.com*
// @version 1
// ==/UserScript==


var yan = document.getElementById('yan'),
h1s = document.querySelectorAll('h1.subject');

[].forEach.call(h1s, function(node) {
// insert before
yan.parentNode.insertBefore(node.cloneNode(true), yan);
});

►►►► 但现在如何设置相对于“#yan-related”元素的位置?►►►► 我希望新创建的元素遵循#yan-related。

最佳答案

这仅适用于脚本,例如

var yan = document.getElementById('yan'),
h1s = document.querySelectorAll('h1.subject');

[].forEach.call(h1s, function(node) {
// insert before
yan.parentNode.insertBefore(node.cloneNode(true), yan);
});

Demo

关于css - 复制一个元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16330191/

59 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com