2014-12-02 50 views
0

我有以下HTML:如何通過ID和Class對具有唯一XPath/CSS選擇器的元素進行相同處理?

<div id="btnCreditCard" class="paymentBtn bitcoin" style="display: none"> 
    <a class="button button-primary button-override has-icon-right" href="javascript:Biz.GlobalShopping.CheckOut.continueToReview(8);"> 
     <i class="button-icon-left"></i>Continue To Order Review<i class="button-icon-right fa fa-caret-right"></i> 
    </a> 
</div> 

<div id="btnMasterPass" class="paymentBtn masterpass" style="display: none;"> 
    <a href="javascript:Biz.GlobalShopping.CheckOut.continueToReview(4);" title="MasterPass" style="cursor: pointer;"> 
     <img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mcpp_wllt_btn_chk_147x034px.png" alt="MasterPass" /> 
    </a> 
</div> 

<div id="btnCreditCard" class="paymentBtn npa" style="display: none"> 
    <a class="button button-primary button-override has-icon-right" href="javascript:Biz.GlobalShopping.CheckOut.continueToReview(5);"> 
     <i class="button-icon-left"></i>Continue To Order Review<i class="button-icon-right fa fa-caret-right"></i> 
    </a> 
</div> 

<div id="btnCreditCard" class="paymentBtn billlater" style="display: none"> 
    <a class="button button-primary button-override has-icon-right" href="javascript:Biz.GlobalShopping.CheckOut.continueToReview(6);"> 
     <i class="button-icon-left"></i>Continue To Order Review<i class="button-icon-right fa fa-caret-right"></i> 
    </a> 
</div> 

我要挑有父DIV <div id="btnCreditCard" class="paymentBtn billlater" style="display: none">錨。我目前使用XPath是('//*[@id="btnCreditCard"]/a')

+1

你也可以使用'// DIV [包含(@類, 'billlater')]/A' – 2014-12-03 11:13:47

回答

3

你可以在XPath使用and

'//*[@id="btnCreditCard" and @class="paymentBtn billlater"]/a' 
+0

驚人。謝謝你,先生!!! – Volatil3 2014-12-02 21:41:28

相關問題