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>
标签文本
建议