gpt4 book ai didi

javascript - jquery 在
中选择多个

转载 作者:太空狗 更新时间:2023-10-29 14:42:24 25 4
gpt4 key购买 nike

HTML:

<div id='example'>
<p> First paragraph</p>
<p> Second paragraph</p>
<p> Third paragraph</p>
</div>

Javascript 与 JQuery:var paragraphs = $('div#examples p');

这将返回一个 HTMLParagraphElement 对象数组。但是,我希望返回 Jquery 对象。 (这样我就可以使用例如:

for(i=0;i<paragraphs.length;i++)
{
paragraph[i].hide();
}

有什么方法可以轻松做到这一点?谢谢。

最佳答案

例子:

$('#examples p').hide();

div 不是必需的

关于javascript - jquery 在 <div> 中选择多个 <p>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5241868/

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