Use jQuery :has() and :contains() selectors together

I have a list item element that contains a label element. I want to select the list item element with the `:has()` selector. Inside the label element there is text I want to match with `:contains()`. Is it possible to do both of these things with a single line of jQuery? If not, what is an elegant way to select the li element based on the contents of its child label element?

  • $("li:has(label):contains('Label 1'))? My understanding is you want to select the li that both has a label and contains the text Label 1.

    以上就是Use jQuery :has() and :contains() selectors together的详细内容,更多请关注web前端其它相关文章!

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

    评论 抢沙发

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

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