加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

phpQuery中最接近的方法?

发布时间:2020-12-13 16:44:50 所属栏目:PHP教程 来源:网络整理
导读:我试图看看是否有办法实施 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()
我试图看看是否有办法实施
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().

因此,当phpQuery中存在parents()时,您可以使用源代码中的示例

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读