[removed] use xpath in jQuery

前端 未结 8 1348
耶瑟儿~
耶瑟儿~ 2020-12-14 10:16

I have, for example, the next XPath query:

//div[span=\"something\"]/parent::div/child::div[@class=\\\"someClass\\\"]

I want to use this XP

相关标签:
8条回答
  • 2020-12-14 10:41

    I'm not sure about the parent::div clause, but without it it should look like this:

    $('div[span="something"] div.someClass');
    
    0 讨论(0)
  • 2020-12-14 10:43

    if you want to select an element inside an iframe, from parent window, you should change second parameter of evaulate() function to iframe's document element, like :

    var iFrameDocument = $('iframe#myPage').get(0).contentWindow.document;
    xpathResult = this[0].evaluate(xpathExpression, iFrameDocument, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
    
    0 讨论(0)
提交回复
热议问题