gpt4 book ai didi

javascript - JQuery $(elmnt + "div").each 有办法做到这一点吗?

转载 作者:行者123 更新时间:2023-11-28 11:07:13 27 4
gpt4 key购买 nike

我在互联网上搜索过,甚至不确定 javascript 语言术语中的问题是什么。我想做的就是更改选定表行列内 div 元素的 css。另外,我希望在没有太多臃肿的情况下执行此操作,例如 .children() 因为我只想选择 div 子级而不是其他任何东西。本质上,我在 elmnt 中有一个存储的选定表行列,并且想遍历其中的每个 div 元素。这是代码

$(elmnt + " div").each(function (i){//also tried $(elmnt.div)...  and $(elmnt +".div")...
if(this.style.cssFloat==="right")
this.style.cssFloat="none";
else
this.style.cssFloat="right";
});

我收到的错误是:

Error: Syntax error, unrecognized expression: [object HTMLTableCellElement].div @ ./resources/jquery-1.9.0.min.js:1567

感谢您的帮助

最佳答案

您可以使用find来实现您要查找的内容

Documentation here

$(elmnt).find("div").each(...

关于javascript - JQuery $(elmnt + "div").each 有办法做到这一点吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18389934/

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