문제

Using either CSS3 or XPath expressions, I'd like to know if there is a way to select the element that contains certain HTML comment.

For example:

<table>…</table>
<table> <!--this one --> …</table>

How can I select the 2nd table without using any other attributes? (it may not always be the 2nd table)

도움이 되었습니까?

해결책

With XPath this can be done using the comment() node test:

//table[.//comment()[contains(., 'this one')]]

This selects all table elements containing a comment (at any depth) that contains the text 'this one'.

I'm pretty sure this is impossible with CSS.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top