[英]JavaScript - Removing last() doesn't work correctly?
I have a remove function that remove class.我有一个删除类的删除函数。 It perform correctly except if it found a duplicate .
除非找到重复项,否则它会正确执行。
How could I solve the problem?我怎么能解决这个问题? Here is GIF's
这是 GIF
Correct: https://gyazo.com/cdd6800f4f847d21d97a071241f76242正确: https : //gyazo.com/cdd6800f4f847d21d97a071241f76242
Duplicate name: https://gyazo.com/d166fcf19af8a147fcb2897bfeb695ed重复名称: https : //gyazo.com/d166fcf19af8a147fcb2897bfeb695ed
Here's the code:这是代码:
$('li img[title="' + removedname + '"]:last').parent().parent().removeClass('red lighten-1 white-text selected-item');
HTML HTML
<li class="col 2 zoomIn animated" style="padding: 8px; font-weight: bold; font-size: 16px; animation-delay: 0s;">
<div class="card item-card waves-effect waves-light red lighten-1 white-text selected-item" data-itemnaaaaaaaaaaaame="★ Butterfly Knife | Crimson Web (Field-Tested)" style="margin: 0%; min-height: 295px; width: 245.438px; border-radius: 15px; height: 245px;" id="2761454276">
<div class="iteam" style="text-decoration: underline;text-align: left">Butterfly Knife | Crimson Web</div>
<div class="condition" style="text-align: left;text-size:13px">Field Tested</div>
<div class="center-align" style="padding:6%">
<img title="★ Butterfly Knife | Crimson Web (Field-Tested)" draggable="false" src="https://steamcommunity-a.akamaihd.net/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpovbSsLQJf0ebcZThQ6tCvq4iSqODxMajum25V4dB8xLjD9tjwjgK1_kZoYT30ctKVegM7NFyGrwK5yee90ZDt6ZmazHNluCQ8pSGKMl3kzfs/200fx200">
<div class="" 'floatvalue'="">
Float: 0.11503319442272186
<div class="bitskinscomp" style="font-weight: normal;font-size:12px">BitSkins Price: $111.43 (You save: $-38.15)</div>
<div class="buyer-price center-align">$149.58</div>
</div>
</div>
</div>
</li>
使用最接近的而不是 :last
$('li img[title="' + removedname + '"]').closest('.card').removeClass('red lighten-1 white-text selected-item');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.