我有这段代码
$('.order_box').each(function(index) {
box=$(this);
if(box.find('.order_status').val()=="Payment received") {
box.css('color', 'red');
}
});
它应该读取包含在一堆 div 中的选择的值,并相应地将 css 样式应用于每个 div。div html是:
<div class="order_box">
<h1>Order nr.: 2329268704685016576</h1>
<div class="delivery_info">
--
<span class="titles">Status:
<select class="order_status">
<option class="payment_received" value="Payment received">Payment received</option>
<option class="need_refund" value="Need to refund money">Need to refund money</option>
<option class="waiting_stock" value="Waiting for product/s stock">Waiting for product/s stock</option>
<option class="packing" value="Packing">Packing</option>
<option class="delivered" value="Delivered/Done" selected="selected">Delivered/Done</option>
</select>
</span>
--
</div>
我假设我可能以错误的方式应用每个函数,但我当然不明白为什么。我希望了解我的用法有什么问题,因为这不是我第一次发现自己处于这种情况。