gpt4 book ai didi

php - phpQuery 中最接近的方法?

转载 作者:可可西里 更新时间:2023-10-31 23:23:50 25 4
gpt4 key购买 nike

我想看看有没有办法实现
phpQuery 上的“最接近”方法(就像在 jQuery 上一样)。
有这种事吗?

最佳答案

来自 Commonly Confused Bits Of jQuery :

CLOSEST(SELECTOR)

This is a bit of a well-kept secret, but very useful. It works like parents(), except that it returns only one parent/ancestor. In my experience, you’ll normally want to check for the existence of one particular element in an element’s ancestry, not a whole bunch of them, so I tend to use this more than parents().

因为 parents() 存在于 phpQuery 中,所以您可以使用源代码中的示例

Tip: you can simulate closest() by using parents() and limiting it to one returned element.

$($('#element1').parents('#element2').get(0)).css('background', '#f90');

关于php - phpQuery 中最接近的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10223150/

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