具有相同类名的元素的css选择器

时间:2015-09-30 20:26:39

标签: html css

我需要找到一个带有CSS选择器的元素...该元素与其他元素相同的类名只有区别是父div类 以下是具有相同类的两个元素的html。我只想获得第一个节点,所以我将如何区分

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,它会给我两个节点。 我将如何只得到第一个节点

1 个答案:

答案 0 :(得分:0)

第一个例子有一个区别(除了根节点),可以被利用。这应该只给你第一个节点:

.expanded .product-freight-default-location