0
我嘗試獲取具有特定班級或沒有班級或沒有兩個班級的那些項目。檢查多個班級
這裏是我的html代碼 -
<div id="events">
<ul class="checkout-bar">
<li class=""><span><a href="#">Order</a></span></li>
<li class=""><span><a href="#">Booking</a></span></li>
<li class="t-completed"><span><a href="#">Receiving</a></span></li>
<li class="t-completed"><span><a href="#">Loading</a></span></li>
<li class="t-completed active"><span><a href="#">Arrival</a></span></li>
<li class="inactive"><span><a href="#">Arrival</a></span></li>
<li class="inactive"><span><a href="#">Availability</a></span></li>
<li class="inactive"><span><a href="#">Delivery</a></span></li>
</ul>
</div>
現在,我想有空類來獲得這些鏈接標記(),具有「t-completed
」類li
且其文本,哪些還沒有「t-completed
」和'active
' 類即<li class="t-completed active">
嘗試使用jQuery -
if($('#events .checkout-bar li').length>0){
$('#events .checkout-bar li').each(function(){
var t = $(this);
if (!t.hasClass() || (t.hasClass("ms-completed") && !t.hasClass("active"))){
//if($(this).is('.ms-completed:not(.active)') || $(this).attr('class')==""){
var oldtxt = $(t).find('span a').text();
if(oldtxt == 'Order'){
t.find('span a').text("Ordered");
}else if(oldtxt == 'Booking'){
t.find('span a').text("Booked");
}else if(oldtxt == 'Receiving'){
t.find('span a').text("Received");
}else if(oldtxt == 'Loading'){
t.find('span a').text("Loaded");
}else if(oldtxt == 'Arrival'){
t.find('span a').text("Arrived");
}else if(oldtxt == 'Availability'){
t.find('span a').text("Available");
}else if(oldtxt == 'Delivery'){
t.find('span a').text("Delivered");
}else if(oldtxt == 'In transit'){
t.find('span a').text("Transited");
}else{
t.find('span a').text(oldtxt);
}
}
});
}
替換那些<a>
標記文本,其中<li>
具有空的("")
類,並且只有"ms-completed"
類。目前,替代其<li>
有「MS-完成主動」類的<a>
標籤文本
建議