2015-09-30 124 views
-1

我需要找到一個CSS選擇器的元素...該元素與其他元素相同的類名只有不同是父div類 以下是兩個HTML具有相同類的元素。我想第一個節點只讓我將如何區分CSS選擇器的元素,它具有相同的類名

1.

<div class="ResponsiveContainer"> 
<div class="js-slide-panel-content display-block-m"> 
<div class="product-fulfillment-content copy-small module js-tab-ship product-buying-table-row-alt expanded"> 
<div class="tab-pointer tab-pointer-one hide-content display-inline-block-m"/> 
<h3 class="fulfillment-logo-in-slide-panel"> 
<b class="js-product-fulfillment-default-location product-freight-default-location">Showing options for 94066</b> 
<div class="js-product-fulfillment-table product-fulfillment-table bot-padding"> 

2.

<div class="js-pickup-slide-panel pickup-slide-panel-section product-buying-table-row-alt"> 
<div class="ResponsiveContainer"> 
<div class="js-slide-panel-content display-block-m"> 
<div class="product-fulfillment-content copy-small module js-tab-pickup product-buying-table-row-alt"> 
<div class="tab-pointer tab-pointer-two hide-content display-inline-block-m"/> 
<h3 class="fulfillment-logo-in-slide-panel"> 
<b class="js-product-fulfillment-default-location product-freight-default-location">Showing options for 94066</b> 
<div class="js-product-fulfillment-table product-fulfillment-table bot-padding"> 

所以,如果我給CSS選擇.js-product-fulfillment-default-location product-freight-default-location它給我兩個節點。 我將如何獲得只有第一個節點

+0

http://stackoverflow.com/questions/2717480/css-selector-for-first-element-with-class – Shockwave

回答

0

第一個示例有一個區別(除了根節點),可以利用。這應該給你只有第一個節點:

.expanded .product-freight-default-location 
+0

是它給我的第一個節點。謝謝。 – nodemongo

+0

@nodemongo如果解決了您的問題,請將答案標記爲已接受。 – levininja

相關問題