gpt4 book ai didi

javascript - 相当于纯 JS 中 jQuery 的 content().find() 链式方法

转载 作者:行者123 更新时间:2023-12-02 21:10:54 25 4
gpt4 key购买 nike

所以我一直在尝试在没有 jQuery 的情况下执行以下代码:

$(".parent-class").contents().find(".child-class").css("color", "red");

我正在尝试编辑嵌入的 Twitter feed 的样式,我只能通过使用以下代码段获取模块的子节点来做到这一点:$(".twitter-timeline").find(".timeline-Tweet-text").css("margin-bottom", "-10px"); 无论出于何种原因。纯 JS 代码模仿此功能是必要的。我的完整 js 函数是:

// Change the style of the tweets after the module loads.
window.addEventListener('load', function () {
$(".twitter-timeline").contents().find(".timeline-Tweet-text").css("margin-bottom", "-10px");
});

感谢您花时间阅读。

最佳答案

您可以尝试以下方法:

document.querySelectorAll(".twitter-timeline .timeline-Tweet-text").forEach(function(el){
el.style.marginBottom = "-10px";
});

关于javascript - 相当于纯 JS 中 jQuery 的 content().find() 链式方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61099280/

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