gpt4 book ai didi

javascript - jquery加载选择一个特定的类

转载 作者:太空狗 更新时间:2023-10-29 13:44:44 26 4
gpt4 key购买 nike

所以我像这样使用 Jquery 的加载函数,

$('#id').load("http://www.thisiswhyimbroke.com");

我知道你可以在 url 后添加 id 选择器,但我要查找的内容不包含在 id 中,有没有办法让我选择特定的类名?

更进一步,如果我可以选择第一个 li 项,然后选择其中包含 name 项的类,这可能吗?

最佳答案

你可以提供任何选择器,例如

$('#id').load("http://www.thisiswhyimbroke.com li:first .someclass");

来自documentation :

Loading Page Fragments

The .load() method, unlike $.get(), allows us to specify a portion of the remote document to be inserted. This is achieved with a special syntax for the url parameter. If one or more space characters are included in the string, the portion of the string following the first space is assumed to be a jQuery selector that determines the content to be loaded.

关于javascript - jquery加载选择一个特定的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14675354/

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