开发者

Xpath and innerHTML

What Xpat开发者_开发百科h expression can I use to find all the anchor (just 'a') elements whose actual text (the innerHTML) is Logout.

something like

//a[@innerHTML='Logout']

Would that be correct?


No, it would be incorrect. innerHTML is a property, part of the object model, while XPath operates on tags and attributes. Unless your a tag actually has an attribute named innerHTML, this wouldn't work.

If you want to compare the value of the tag itself, you can use the . (dot) to refer to the tag:

a[.='Logout']

However, I must add, just in case you're using jQuery: I'm not sure if it will work with jQuery. jQuery does not support XPath fully, only basic stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜