好的,所以我有这个 HTML,我正在尝试设置它的样式,以便购物车的每一行都从白色变为灰色。我知道这可能使用 CSS3 更容易,但由于这需要支持回到 IE7,我认为 jQuery 可能是更好的途径。
<div id="checkoutTable">
<div id="checkoutRow" class="bold headline">
<div id="checkoutCell" class="headline">Item <br>Number</div>
<div id="checkoutCell" class="headline itemName">Item <br>Name</div>
<div id="checkoutCell" class="headline">Quantity <br>Per Unit</div>
<div id="checkoutCell" class="headline">Units Free <br>Remaining</div>
<div id="checkoutCell" class="headline">Units <br>Ordered</div>
<div id="checkoutCell" class="headline">Cost Per Unit <br>(USD)</div>
<div id="checkoutCell" class="headline">Total Cost <br>(USD)</div>
</div>
<div id="checkoutRow" class="center cartCheckout">
<div id="checkoutCell" class="first">FLT199</div>
<div id="checkoutCell" class="first itemName">Vehicle Flyer</div>
<div id="checkoutCell" class="first">1</div>
<div id="checkoutCell" class="first">20</div>
<div id="checkoutCell" class="first"><input name="unitsOrdered" id="" size="5"></div>
<div id="checkoutCell" class="first">$10.00</div>
<div id="checkoutCell" class="first">$0.00</div>
</div>
<div id="checkoutRow" class="center cartCheckout">
<div id="checkoutCell" class="first">FLT199</div>
<div id="checkoutCell" class="first itemName">Vehicle Flyer</div>
<div id="checkoutCell" class="first">1</div>
<div id="checkoutCell" class="first">20</div>
<div id="checkoutCell" class="first"><input name="unitsOrdered" id="" size="5"></div>
<div id="checkoutCell" class="first">$10.00</div>
<div id="checkoutCell" class="first">$0.00</div>
</div>
</div>
然后我认为这个 jQuery 可以解决问题,但它不起作用。
$(function() {
$(".cartCheckout:even").css("background", "#ccc;");
});