gpt4 book ai didi

javascript - Jquery检查tr是否没有带类的项目并删除重复项

转载 作者:行者123 更新时间:2023-11-28 02:27:41 24 4
gpt4 key购买 nike

我有这样的html表:

<div class="1233">hello</div>
<table cellpadding="0" cellspasing="0" class="sortable zebra tablesorter tablesorter-default"
id="articles-table">
<thead>
<tr class="tablesorter-headerRow">
<th data-column="0" class="tablesorter-header">
<div class="tablesorter-header-inner">Производитель<i class="tablesorter-icon"></i>
</div>
</th>
<th data-column="1" class="tablesorter-header">
<div class="tablesorter-header-inner">Артикул<i class="tablesorter-icon"></i>
</div>
</th>
<th data-column="2" class="tablesorter-header">
<div class="tablesorter-header-inner">Описание<i class="tablesorter-icon"></i>
</div>
</th>
<th data-column="3" class="tablesorter-header">
<div class="tablesorter-header-inner"><i class="tablesorter-icon"></i>
</div>
</th>
<th class="prcol tablesorter-header tablesorter-headerSortDown" data-column="4">
<div class="tablesorter-header-inner">Цена<i class="tablesorter-icon"></i>
</div>
</th>
<th data-column="5" class="tablesorter-header">
<div class="tablesorter-header-inner">Наличие<i class="tablesorter-icon"></i>
</div>
</th>
<th data-column="6" class="tablesorter-header">
<div class="tablesorter-header-inner">Сроки поставки<i class="tablesorter-icon"></i>
</div>
</th>
<th data-column="7" class="tablesorter-header">
<div class="tablesorter-header-inner"><i class="tablesorter-icon"></i>
</div>
</th>
</tr>
</thead>
<tbody class="analogs_art">
<tr class="zebra-stripe zebra-grey zebra2 even">
<td>
<h5>Knecht</h5>
</td>
<td>
<h4>OC90</h4>
</td>
<td style="max-width: 300px;">(07786171)Фильтр масл OPEL (07786171)Фильтр масл OPEL</td>
<td></td>
<td>6124</td>
<td>20</td>
<td>0-1</td>
<td id="to_cart_and_qnt_td">
<form accept-charset="UTF-8" action="/line_items" method="post">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓">
<input name="authenticity_token" type="hidden" value="0jlRLSkDKi6eM5SSL+3uRB0w2G141KUcJKuy4Bg2YNo=">
</div>
<input id="ART" name="ART" type="hidden" value="y1M1ZtdXgnMe6pOjjuXWPqhYR41SmQRKzlDOQ1uPwuru+AamPGpcOwOFFylbRDu5M1XUawCnukqNDQCuIr0JPA==--vNGx6/lYKRrpD5NGTJALcQ==">
<input id="price" name="price" type="hidden" value="TodzvfOZCbK5T9+RLE1IQg==--qq8o30c5rTX91F8W42wdsQ==">
<input id="distributor_id" name="distributor_id" type="hidden" value="6">
<input id="waittime" name="waittime" type="hidden" value="1">
<input class="qnt_to_cart2" id="OC90" name="cart_quantity" pattern="0|[1-9]\d{0,2}"
required="required" type="text" value="1">
<input class="orange-button to-cart_no" id="OC90" name="commit" type="submit"
value="В корзину">
</form>
</td>
</tr>
<tr class="zebra-stripe zebra-grey zebra2 odd">
<td>
<h5>KNECHT</h5>
</td>
<td>
<h4>OC 90</h4>
</td>
<td style="max-width: 300px;">Масляный фильтр</td>
<td> <a href="/articles/1248525/details" class="details-link">подробнее</a>

<a
href="/articles/1248525" class="analogs-link">аналоги</a>
</td>
<td>6124</td>
<td>20</td>
<td>0-1</td>
<td id="to_cart_and_qnt_td">
<form accept-charset="UTF-8" action="/line_items" method="post">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓">
<input name="authenticity_token" type="hidden" value="0jlRLSkDKi6eM5SSL+3uRB0w2G141KUcJKuy4Bg2YNo=">
</div>
<input id="ART" name="ART" type="hidden" value="9x6mdLbW2aMaHqFK32kZwHWnWA7n0GBp/jXS8KeECsTS+78ytG0SQzFpVODplws5iHm6B6SkZzi3ej2+zpW8iQ==--RNoUUgcZu7MLU8BHJ4ynSQ==">
<input id="price" name="price" type="hidden" value="VqatEYzkPEf3P9Y/jNY9Zg==--Iw5nQDqjK9vvZX/RecD1eA==">
<input id="distributor_id" name="distributor_id" type="hidden" value="6">
<input id="waittime" name="waittime" type="hidden" value="1">
<input class="qnt_to_cart" id="cart_quantity" name="cart_quantity" pattern="0|[1-9]\d{0,2}"
required="required" type="text" value="1">
<input class="orange-button to-cart" name="commit" type="submit" value="В корзину">
</form>
</td>
</tr>
<tr class="zebra-stripe zebra-grey zebra1 even">
<td>
<h5>Knecht</h5>
</td>
<td>
<h4>OC90</h4>
</td>
<td style="max-width: 300px;">Фильтр масляный OPEL/GM/DAEWOO Фильтр масляный OPEL/GM/DAEWOO</td>
<td></td>
<td>6142</td>
<td>1000</td>
<td>3</td>
<td id="to_cart_and_qnt_td">
<form accept-charset="UTF-8" action="/line_items" method="post">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓">
<input name="authenticity_token" type="hidden" value="0jlRLSkDKi6eM5SSL+3uRB0w2G141KUcJKuy4Bg2YNo=">
</div>
<input id="ART" name="ART" type="hidden" value="NqgWSvcdv0FEQkjcJZp98gIYe20Fjol8Bn31tB/CjWnTFVsa3J3hmldO1RSqS/pNUcVZ5dh0wcP7YeZxPAkQc4DEPKy7EVuTpMw3oQw58T0=--/XCn0hP3w0mglJ1vTXSjHw==">
<input id="price" name="price" type="hidden" value="mFPLSHh7AdEMpQJiZHFKNg==--hfJQGWhjBoD6mNAetXZ3Xw==">
<input id="distributor_id" name="distributor_id" type="hidden" value="6">
<input id="waittime" name="waittime" type="hidden" value="3">
<input class="qnt_to_cart2" id="OC90" name="cart_quantity" pattern="0|[1-9]\d{0,2}"
required="required" type="text" value="1">
<input class="orange-button to-cart_no" id="OC90" name="commit" type="submit"
value="В корзину">
</form>
</td>
</tr>
</tbody>
</table>

如何在我的 jscript 中:

if(tr.not('.details-link')){

我可以不理会这样的td,因为我没有 class =Details-link 吗?现在我的代码无法工作......

只需跳过编辑我的代码,这样如果 tr 没有类,我会做一些事情......如何做到这一点?

更新我需要这样做:<强> http://jsfiddle.net/zvKSc/8/

删除重复项(通过小写的1,2,5列和删除空格必须相等...),但在页面上留下这样的tr,其中在td之一中我有类详细信息链接...所以在 fiddle 中从三个我必须首先删除,并留下第二个和第三个tr

最佳答案

if(!$('tr').hasClass('details-link')) {

// code to execute if tr does not have class

}

查看hasClass方法:http://api.jquery.com/hasClass/

关于javascript - Jquery检查tr是否没有带类的项目并删除重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14656715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com