:has CSS pseudo class in Nokogiri

I'm looking for the pseudoclass `:has` in [Nokogiri][1]. It should work just like jQuery's [`has` selector][2]. For example:
  • ex1

    sdfsdf
  • ex2

  • ex3

  • The CSS selector should return only the first link, the one with the not-empty `span.string` sibling. In jQuery this selector works well: $('li:has(span.string:not(:empty))>h1>a') but not in Nokogiri: Nokogiri::HTML(html_source).css('li:has(span.string:not(:empty))>h1>a') `:not` and `:empty` works well, but not `:has`. --- 1. Is there any documentation for CSS selectors in Nokogiri? 2. Maybe someone can write a custom `:has` pseudo class? Here is an [example][3] how to write a `:regexp` selector. 3. Optionally I can use XPath. How do I write XPath for `li:has(span.string:not(:empty))>h1>a`? [1]: http://nokogiri.org/Nokogiri/XML/Node.html [2]: http://api.jquery.com/has-selector/ [3]: http://nokogiri.org/Nokogiri/XML/Node.html#method-i-css
    :has pseudo is a jQuery extension, so I guess that Nokogiri does not support it because it's not part of any standard.

    以上就是:has CSS pseudo class in Nokogiri的详细内容,更多请关注web前端其它相关文章!

    赞(0) 打赏
    未经允许不得转载:web前端首页 » jQuery 答疑

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址

    前端开发相关广告投放 更专业 更精准

    联系我们

    觉得文章有用就打赏一下文章作者

    支付宝扫一扫打赏

    微信扫一扫打赏